diff options
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/libsmb/cliconnect.c | 15 | ||||
-rw-r--r-- | source3/libsmb/libsmb_dir.c | 25 | ||||
-rw-r--r-- | source3/libsmb/namequery.c | 21 |
4 files changed, 37 insertions, 27 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index eccf0f9400..c296487eac 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1958,7 +1958,8 @@ NTSTATUS name_query(const char *name, int name_type, int *num_addrs, uint8_t *flags); NTSTATUS name_resolve_bcast(const char *name, int name_type, - struct ip_service **return_iplist, + TALLOC_CTX *mem_ctx, + struct sockaddr_storage **return_iplist, int *return_count); NTSTATUS resolve_wins(const char *name, int name_type, diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index cb7b7d1bbd..1383978c91 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -3472,9 +3472,10 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx, const struct user_auth_info *user_info, char **pp_workgroup_out) { - struct ip_service *ip_list; + struct sockaddr_storage *ip_list; struct cli_state *cli; int i, count; + NTSTATUS status; *pp_workgroup_out = NULL; @@ -3482,18 +3483,20 @@ struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx, /* Go looking for workgroups by broadcasting on the local network */ - if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list, - &count))) { - DEBUG(99, ("No master browsers responded\n")); + status = name_resolve_bcast(MSBROWSE, 1, talloc_tos(), + &ip_list, &count); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(99, ("No master browsers responded: %s\n", + nt_errstr(status))); return False; } for (i = 0; i < count; i++) { char addr[INET6_ADDRSTRLEN]; - print_sockaddr(addr, sizeof(addr), &ip_list[i].ss); + print_sockaddr(addr, sizeof(addr), &ip_list[i]); DEBUG(99, ("Found master browser %s\n", addr)); - cli = get_ipc_connect_master_ip(ctx, &ip_list[i].ss, + cli = get_ipc_connect_master_ip(ctx, &ip_list[i], user_info, pp_workgroup_out); if (cli) return(cli); diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index b0f3c904b4..3602bc5377 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -456,9 +456,10 @@ SMBC_opendir_ctx(SMBCCTX *context, int i; int count; int max_lmb_count; - struct ip_service *ip_list; - struct ip_service server_addr; + struct sockaddr_storage *ip_list; + struct sockaddr_storage server_addr; struct user_auth_info u_info; + NTSTATUS status; if (share[0] != (char)0 || path[0] != (char)0) { @@ -498,13 +499,14 @@ SMBC_opendir_ctx(SMBCCTX *context, */ ip_list = NULL; - if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list, - &count))) + status = name_resolve_bcast(MSBROWSE, 1, talloc_tos(), + &ip_list, &count); + if (!NT_STATUS_IS_OK(status)) { - SAFE_FREE(ip_list); + TALLOC_FREE(ip_list); - if (!find_master_ip(workgroup, &server_addr.ss)) { + if (!find_master_ip(workgroup, &server_addr)) { if (dir) { SAFE_FREE(dir->fname); @@ -515,8 +517,9 @@ SMBC_opendir_ctx(SMBCCTX *context, return NULL; } - ip_list = (struct ip_service *)memdup( - &server_addr, sizeof(server_addr)); + ip_list = (struct sockaddr_storage *)talloc_memdup( + talloc_tos(), &server_addr, + sizeof(server_addr)); if (ip_list == NULL) { if (dir) { SAFE_FREE(dir->fname); @@ -534,13 +537,13 @@ SMBC_opendir_ctx(SMBCCTX *context, char *wg_ptr = NULL; struct cli_state *cli = NULL; - print_sockaddr(addr, sizeof(addr), &ip_list[i].ss); + print_sockaddr(addr, sizeof(addr), &ip_list[i]); DEBUG(99, ("Found master browser %d of %d: %s\n", i+1, MAX(count, max_lmb_count), addr)); cli = get_ipc_connect_master_ip(talloc_tos(), - &ip_list[i].ss, + &ip_list[i], &u_info, &wg_ptr); /* cli == NULL is the master browser refused to talk or @@ -594,7 +597,7 @@ SMBC_opendir_ctx(SMBCCTX *context, } } - SAFE_FREE(ip_list); + TALLOC_FREE(ip_list); } else { /* * Server not an empty string ... Check the rest and see what diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 61814f490c..49b2061c09 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1489,7 +1489,8 @@ static bool convert_ss2service(struct ip_service **return_iplist, NTSTATUS name_resolve_bcast(const char *name, int name_type, - struct ip_service **return_iplist, + TALLOC_CTX *mem_ctx, + struct sockaddr_storage **return_iplist, int *return_count) { int i; @@ -1537,11 +1538,7 @@ NTSTATUS name_resolve_bcast(const char *name, return status; success: - - if (!convert_ss2service(return_iplist, ss_list, *return_count) ) - status = NT_STATUS_NO_MEMORY; - - TALLOC_FREE(ss_list); + *return_iplist = ss_list; return status; } @@ -2075,10 +2072,16 @@ NTSTATUS internal_resolve_name(const char *name, } } } else if(strequal( tok, "bcast")) { - status = name_resolve_bcast(name, name_type, - return_iplist, - return_count); + struct sockaddr_storage *ss_list; + status = name_resolve_bcast( + name, name_type, talloc_tos(), + &ss_list, return_count); if (NT_STATUS_IS_OK(status)) { + if (!convert_ss2service(return_iplist, + ss_list, + *return_count)) { + status = NT_STATUS_NO_MEMORY; + } goto done; } } else { |