From: Jeremy Allison Date: Thu, 27 Aug 2020 16:49:05 +0000 (-0700) Subject: s3: libsmb: Cleanup - correctly error on sockaddr_storage_to_samba_sockaddr() fail. X-Git-Tag: talloc-2.3.2~632 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c28d7151160e64a3f449e4dc34ade4fcb3e1298;p=thirdparty%2Fsamba.git s3: libsmb: Cleanup - correctly error on sockaddr_storage_to_samba_sockaddr() fail. Instead of jumping out and leaking the memory onto ctx, skip bad conversions and error out if there are no addresses to return (and cleanup the memory there). Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 242ec2915ee..6d774ce330e 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -3528,8 +3528,7 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx, ok = sockaddr_storage_to_samba_sockaddr(&sa, &ss_list[i].ss); if (!ok) { - status = NT_STATUS_INVALID_ADDRESS; - goto done; + continue; } if (!is_zero_addr(&sa.u.ss) && !is_broadcast_addr(&sa.u.sa)) { @@ -3556,8 +3555,7 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx, ok = sockaddr_storage_to_samba_sockaddr(&sa, &ss_list[i].ss); if (!ok) { - status = NT_STATUS_INVALID_ADDRESS; - goto done; + continue; } if (!is_zero_addr(&sa.u.ss) && !is_broadcast_addr(&sa.u.sa)) { @@ -3565,6 +3563,12 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx, } } + if (num_entries == 0) { + TALLOC_FREE(*return_ss_arr); + status = NT_STATUS_BAD_NETWORK_NAME; + goto done; + } + status = NT_STATUS_OK; *p_num_entries = num_entries; done: