s3/libads: simplify storing existing ads->ldap.ss
authorRalph Boehme <slow@samba.org>
Mon, 31 Jan 2022 11:54:12 +0000 (12:54 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 8 Feb 2022 19:27:29 +0000 (19:27 +0000)
We just need temporal storage for ads->ldap.ss, no need to store it as a struct
samba_sockaddr.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14674
MR: https://gitlab.com/samba-team/samba/-/merge_requests/2354

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libads/ldap.c

index 1bc271785e2a258021f37d2175e4407b42aeb1e8..28f396f0fe4a68cc07342ced8e36fbfbf99c9ee5 100755 (executable)
@@ -605,7 +605,7 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
        ADS_STATUS status;
        NTSTATUS ntstatus;
        char addr[INET6_ADDRSTRLEN];
-       struct samba_sockaddr existing_sa = {0};
+       struct sockaddr_storage existing_ss = {0};
 
        /*
         * ads_connect can be passed in a reused ADS_STRUCT
@@ -627,11 +627,7 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
         */
        if (ads->server.ldap_server == NULL && !is_zero_addr(&ads->ldap.ss)) {
                /* Save off the address we previously found by ads_find_dc(). */
-               bool ok = sockaddr_storage_to_samba_sockaddr(&existing_sa,
-                                                            &ads->ldap.ss);
-               if (!ok) {
-                       return ADS_ERROR_NT(NT_STATUS_INVALID_ADDRESS);
-               }
+               existing_ss = ads->ldap.ss;
        }
 
        ads_zero_ldap(ads);
@@ -679,11 +675,11 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
                }
        }
 
-       if (!is_zero_addr(&existing_sa.u.ss)) {
+       if (!is_zero_addr(&existing_ss)) {
                /* We saved off who we should talk to. */
                bool ok = ads_try_connect(ads,
                                          ads->server.gc,
-                                         &existing_sa.u.ss);
+                                         &existing_ss);
                if (ok) {
                        goto got_connection;
                }