s3: libsmb: Fix resolve_hosts() to return size_t * count of addresses.
authorJeremy Allison <jra@samba.org>
Tue, 8 Sep 2020 22:18:33 +0000 (15:18 -0700)
committerNoel Power <npower@samba.org>
Tue, 15 Sep 2020 10:09:37 +0000 (10:09 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/libsmb/namequery.c

index 649ba8a6de54b838d11e7191fa02f8dc8e8ab5a8..7fda3ab75fbc84507356efdec0f37d292b64bc70 100644 (file)
@@ -2845,7 +2845,7 @@ static NTSTATUS resolve_hosts(TALLOC_CTX *mem_ctx,
                              const char *name,
                              int name_type,
                              struct sockaddr_storage **return_iplist,
-                             int *return_count)
+                             size_t *return_count)
 {
        /*
         * "host" means do a localhost, or dns lookup.
@@ -2926,10 +2926,7 @@ static NTSTATUS resolve_hosts(TALLOC_CTX *mem_ctx,
        if (ret_count == 0) {
                return NT_STATUS_UNSUCCESSFUL;
        }
-       if ((int)ret_count < 0) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
-       *return_count = (int)ret_count;
+       *return_count = ret_count;
        *return_iplist = iplist;
        return NT_STATUS_OK;
 }
@@ -3376,14 +3373,21 @@ NTSTATUS internal_resolve_name(TALLOC_CTX *ctx,
                tok = resolve_order[i];
 
                if((strequal(tok, "host") || strequal(tok, "hosts"))) {
+                       size_t hcount = 0;
                        status = resolve_hosts(talloc_tos(),
                                               name,
                                               name_type,
                                               &ss_list,
-                                              &icount);
+                                              &hcount);
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
+                       /*
+                        * This uglyness will go away once
+                        * all resolve_XXX() return size_t *
+                        * number of addresses.
+                        */
+                       icount = (int)hcount;
                        goto done;
                } else if(strequal( tok, "kdc")) {
                        /* deal with KDC_NAME_TYPE names here.