]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Cleanup - correctly error on sockaddr_storage_to_samba_sockaddr() fail.
authorJeremy Allison <jra@samba.org>
Thu, 27 Aug 2020 16:49:05 +0000 (09:49 -0700)
committerNoel Power <npower@samba.org>
Mon, 7 Sep 2020 13:23:40 +0000 (13:23 +0000)
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 <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/libsmb/namequery.c

index 242ec2915ee68fd80694db9885b34b47a2cda1c6..6d774ce330ec6a2c8d94b0d6807470899f854b19 100644 (file)
@@ -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: