Will make converting _internal_resolve_name() to return a size_t easier.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Remove any duplicate address/port pairs in the list
*********************************************************************/
-int remove_duplicate_addrs2(struct ip_service *iplist, int count )
+size_t remove_duplicate_addrs2(struct ip_service *iplist, size_t count )
{
- int i, j;
+ size_t i, j;
DEBUG(10,("remove_duplicate_addrs2: "
"looking for duplicate address/port pairs\n"));
if (ok) {
*return_count = remove_duplicate_addrs2(*return_iplist,
*return_count );
- /* This could be a negative response */
if (*return_count > 0) {
TALLOC_FREE(frame);
return NT_STATUS_OK;
controllers including the PDC in iplist[1..n]. Iterating over
the iplist when the PDC is down will cause two sets of timeouts. */
- *return_count = remove_duplicate_addrs2(*return_iplist, *return_count );
+ *return_count = (int)remove_duplicate_addrs2(*return_iplist,
+ *return_count );
+ /* Paranoia casting size_t -> int. */
+ if (*return_count < 0) {
+ SAFE_FREE(*return_iplist);
+ *return_count = 0;
+ TALLOC_FREE(frame);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
/* Save in name cache */
if ( DEBUGLEVEL >= 100 ) {
int type,
const struct sockaddr_storage *to_ss,
fstring name);
-int remove_duplicate_addrs2(struct ip_service *iplist, int count );
+size_t remove_duplicate_addrs2(struct ip_service *iplist, size_t count );
struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *name, int name_type,
static bool run_local_remove_duplicate_addrs2(int dummy)
{
struct ip_service test_vector[28];
- int count, i;
+ size_t count, i;
/* Construct the sockaddr_storage test vector. */
for (i = 0; i < 28; i++) {
count = remove_duplicate_addrs2(test_vector, i);
if (count != 14) {
- fprintf(stderr, "count wrong (%d) should be 14\n",
+ fprintf(stderr, "count wrong (%zu) should be 14\n",
count);
return false;
}
print_sockaddr(addr, sizeof(addr), &test_vector[i].ss);
if (strcmp(addr, remove_duplicate_addrs2_test_strings_result[i]) != 0) {
- fprintf(stderr, "mismatch on [%d] [%s] [%s]\n",
+ fprintf(stderr, "mismatch on [%zu] [%s] [%s]\n",
i,
addr,
remove_duplicate_addrs2_test_strings_result[i]);