]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: nbt: Fix resolve_lmhosts_file_as_sockaddr() to return size_t * count of addre...
authorJeremy Allison <jra@samba.org>
Tue, 8 Sep 2020 20:58:49 +0000 (13:58 -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>
libcli/nbt/libnbt.h
libcli/nbt/lmhosts.c
source3/libsmb/namequery.c
source4/libcli/resolve/lmhosts.c

index 496b2b9178376eacd009ad9e517d4fe2e120e4ec..204484be73f6f41dfb31d8faff72d6640c52d8d2 100644 (file)
@@ -372,6 +372,6 @@ NTSTATUS resolve_lmhosts_file_as_sockaddr(TALLOC_CTX *mem_ctx,
                                          const char *name,
                                          int name_type,
                                          struct sockaddr_storage **return_iplist,
-                                         int *return_count);
+                                         size_t *return_count);
 
 #endif /* __LIBNBT_H__ */
index 7c00567fdba377373a0ff60c1bab5cf5b3031d8b..dd06e70c071e2ba37f0d83275cadd06b38620f6c 100644 (file)
@@ -164,7 +164,7 @@ NTSTATUS resolve_lmhosts_file_as_sockaddr(TALLOC_CTX *mem_ctx,
                                          const char *name,
                                          int name_type,
                                          struct sockaddr_storage **return_iplist,
-                                         int *return_count)
+                                         size_t *return_count)
 {
        /*
         * "lmhosts" means parse the local lmhosts file.
@@ -234,11 +234,6 @@ NTSTATUS resolve_lmhosts_file_as_sockaddr(TALLOC_CTX *mem_ctx,
                        break;
        }
 
-       if ((int)ret_count < 0) {
-               TALLOC_FREE(ctx);
-               endlmhosts(fp);
-               return NT_STATUS_INVALID_PARAMETER;
-       }
        *return_count = ret_count;
        *return_iplist = talloc_move(mem_ctx, &iplist);
        TALLOC_FREE(ctx);
index 324f391cc4dc51370c90a5211571e68f3f23a649..67f3f29c7cb3fe93862dfa532f891c023414c5f6 100644 (file)
@@ -3406,16 +3406,23 @@ NTSTATUS internal_resolve_name(TALLOC_CTX *ctx,
                        }
                        goto done;
                } else if (strequal(tok, "lmhosts")) {
+                       size_t lmcount = 0;
                        status = resolve_lmhosts_file_as_sockaddr(
                                talloc_tos(),
                                get_dyn_LMHOSTSFILE(),
                                name,
                                name_type,
                                &ss_list,
-                               &icount);
+                               &lmcount);
                        if (!NT_STATUS_IS_OK(status)) {
                                continue;
                        }
+                       /*
+                        * This uglyness will go away once
+                        * all resolve_XXX() return size_t *
+                        * number of addresses.
+                        */
+                       icount = (int)lmcount;
                        goto done;
                } else if (strequal(tok, "wins")) {
                        size_t wcount = 0;
index 0f2cf99b459e627907ff979a6252e712cbc0ac77..244a9a3ceafe1cec5eb1aff3fd048dbb431c6040 100644 (file)
@@ -53,7 +53,7 @@ static struct composite_context *resolve_name_lmhosts_send(
        struct composite_context *c;
        struct resolve_lmhosts_state *state;
        struct sockaddr_storage *resolved_iplist;
-       int resolved_count, i;
+       size_t resolved_count = 0, i;
 
        if (event_ctx == NULL) {
                return NULL;