]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:passdb: Fix possible memory leak in secrets_fetch_ipc_userpass()
authorPavel Filipenský <pfilipensky@samba.org>
Thu, 11 Aug 2022 08:39:37 +0000 (10:39 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 26 Aug 2022 07:59:32 +0000 (07:59 +0000)
If domain or username are empty strings (""), we need to free them.

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/passdb/secrets.c

index 0ad216aaf4e5d87b591dab07bf77487d526f7e16..e88158fb69a59cae99149931b6c5f5c04e5061ec 100644 (file)
@@ -469,8 +469,10 @@ void secrets_fetch_ipc_userpass(char **username, char **domain, char **password)
 
        if (*username && **username) {
 
-               if (!*domain || !**domain)
+               if (!*domain || !**domain) {
+                       SAFE_FREE(*domain);
                        *domain = smb_xstrdup(lp_workgroup());
+               }
 
                if (!*password || !**password) {
                        BURN_FREE_STR(*password);
@@ -482,6 +484,8 @@ void secrets_fetch_ipc_userpass(char **username, char **domain, char **password)
 
        } else {
                DEBUG(3, ("IPC$ connections done anonymously\n"));
+               SAFE_FREE(*username);
+               SAFE_FREE(*domain);
                BURN_FREE_STR(*password);
                *username = smb_xstrdup("");
                *domain = smb_xstrdup("");