summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2020-09-08 13:58:49 -0700
committerNoel Power <npower@samba.org>2020-09-15 10:09:37 +0000
commite034072c96962754a222b5d4d436db4c4256a7f3 (patch)
treebf59097108c8d2e7fb61d8c8aa3bc282379233f0
parentda9c7b193804b6f5259ca13482660f04b7c5dc1b (diff)
downloadsamba-e034072c96962754a222b5d4d436db4c4256a7f3.tar.gz
libcli: nbt: Fix resolve_lmhosts_file_as_sockaddr() to return size_t * count of addresses.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
-rw-r--r--libcli/nbt/libnbt.h2
-rw-r--r--libcli/nbt/lmhosts.c7
-rw-r--r--source3/libsmb/namequery.c9
-rw-r--r--source4/libcli/resolve/lmhosts.c2
4 files changed, 11 insertions, 9 deletions
diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 496b2b91783..204484be73f 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -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__ */
diff --git a/libcli/nbt/lmhosts.c b/libcli/nbt/lmhosts.c
index 7c00567fdba..dd06e70c071 100644
--- a/libcli/nbt/lmhosts.c
+++ b/libcli/nbt/lmhosts.c
@@ -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);
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 324f391cc4d..67f3f29c7cb 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -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;
diff --git a/source4/libcli/resolve/lmhosts.c b/source4/libcli/resolve/lmhosts.c
index 0f2cf99b459..244a9a3ceaf 100644
--- a/source4/libcli/resolve/lmhosts.c
+++ b/source4/libcli/resolve/lmhosts.c
@@ -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;