]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Inside get_dc_list() move one more sockaddr_storage -> samba_sockaddr.
authorJeremy Allison <jra@samba.org>
Wed, 26 Aug 2020 19:35:42 +0000 (12:35 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 27 Aug 2020 06:52:30 +0000 (06:52 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/namequery.c

index af6efc635697f9108a61958256c72f3a6d7ba1a3..57f2222b904c9b09ede515934db840972a99b0bc 100644 (file)
@@ -3777,7 +3777,7 @@ static NTSTATUS get_dc_list(const char *domain,
 
        while ((local_count<num_addresses) &&
                        next_token_talloc(ctx, &p, &name, LIST_SEP)) {
-               struct sockaddr_storage name_ss;
+               struct samba_sockaddr name_sa = {0};
 
                /* copy any addresses from the auto lookup */
 
@@ -3828,11 +3828,27 @@ static NTSTATUS get_dc_list(const char *domain,
 
                /* explicit lookup; resolve_name() will
                 * handle names & IP addresses */
-               if (resolve_name( name, &name_ss, 0x20, true )) {
+               if (resolve_name(name, &name_sa.u.ss, 0x20, true)) {
                        char addr[INET6_ADDRSTRLEN];
+                       bool ok;
+
+                       /*
+                        * Ensure we set sa_socklen correctly.
+                        * Doesn't matter now, but eventually we
+                        * will remove ip_service and return samba_sockaddr
+                        * arrays directly.
+                        */
+                       ok = sockaddr_storage_to_samba_sockaddr(
+                                       &name_sa,
+                                       &name_sa.u.ss);
+                       if (!ok) {
+                               status = NT_STATUS_INVALID_ADDRESS;
+                               goto out;
+                       }
+
                        print_sockaddr(addr,
                                        sizeof(addr),
-                                       &name_ss);
+                                       &name_sa.u.ss);
 
                        /* Check for and don't copy any known bad DC IP's. */
                        if( !NT_STATUS_IS_OK(check_negative_conn_cache(domain,
@@ -3843,7 +3859,7 @@ static NTSTATUS get_dc_list(const char *domain,
                                continue;
                        }
 
-                       return_iplist[local_count].ss = name_ss;
+                       return_iplist[local_count].ss = name_sa.u.ss;
                        return_iplist[local_count].port = port;
                        local_count++;
                        *ordered = true;