]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/utils: avoid erronous NO MEMORY detection
authorNoel Power <noel.power@suse.com>
Fri, 2 Jun 2023 13:27:55 +0000 (14:27 +0100)
committerJule Anger <janger@samba.org>
Wed, 2 Aug 2023 11:45:00 +0000 (11:45 +0000)
since 5cc3c1b5f6b0289f91c01b20989558badc28fd61 if we don't have
a realm specified either on cmdline or in conf file we try to
copy (talloc_strdup) a NULL variable which triggers a NO_MEMORY
error when we check the result of the copy

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15384

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sun Jun  4 12:42:16 UTC 2023 on atb-devel-224

(cherry picked from commit 22ab42c1007775abca0b578744d4c18a85cda627)

Autobuild-User(v4-17-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-17-test): Wed Aug  2 11:45:00 UTC 2023 on sn-devel-184

source3/utils/net_ads.c

index dd9341f36378fb12b5f438ebd5cb58883b5b418a..70d05dc541ac65228fe7a89814df0e11d20cd263 100644 (file)
@@ -713,10 +713,12 @@ retry:
        } else if (ads->auth.realm == NULL) {
                const char *c_realm = cli_credentials_get_realm(c->creds);
 
-               ads->auth.realm = talloc_strdup(ads, c_realm);
-               if (ads->auth.realm == NULL) {
-                       TALLOC_FREE(ads);
-                       return ADS_ERROR(LDAP_NO_MEMORY);
+               if (c_realm != NULL) {
+                       ads->auth.realm = talloc_strdup(ads, c_realm);
+                       if (ads->auth.realm == NULL) {
+                               TALLOC_FREE(ads);
+                               return ADS_ERROR(LDAP_NO_MEMORY);
+                       }
                }
        }