auth:creds: Free the uname pointer in cli_credentials_parse_string()
authorAndreas Schneider <asn@samba.org>
Mon, 22 Mar 2021 17:11:33 +0000 (18:11 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 24 Mar 2021 03:13:05 +0000 (03:13 +0000)
The data is duplicated and we don't need it anymore.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Mar 24 03:13:05 UTC 2021 on sn-devel-184

auth/credentials/credentials.c

index 6596a227bee38862be2087fbc3397721d1fa68d8..d851951c9ed07c61a2d9c5754e3eaae923d216a2 100644 (file)
@@ -824,6 +824,7 @@ bool cli_credentials_set_workstation_callback(struct cli_credentials *cred,
 _PUBLIC_ void cli_credentials_parse_string(struct cli_credentials *credentials, const char *data, enum credentials_obtained obtained)
 {
        char *uname, *p;
+       char *uname_free = NULL;
 
        if (strcmp("%",data) == 0) {
                cli_credentials_set_anonymous(credentials);
@@ -831,6 +832,8 @@ _PUBLIC_ void cli_credentials_parse_string(struct cli_credentials *credentials,
        }
 
        uname = talloc_strdup(credentials, data); 
+       uname_free = uname;
+
        if ((p = strchr_m(uname,'%'))) {
                *p = 0;
                cli_credentials_set_password(credentials, p+1, obtained);
@@ -848,6 +851,7 @@ _PUBLIC_ void cli_credentials_parse_string(struct cli_credentials *credentials,
                cli_credentials_set_principal(credentials, uname, obtained);
                *p = 0;
                cli_credentials_set_realm(credentials, p+1, obtained);
+               TALLOC_FREE(uname_free);
                return;
        } else if ((p = strchr_m(uname,'\\'))
                   || (p = strchr_m(uname, '/'))
@@ -889,6 +893,8 @@ _PUBLIC_ void cli_credentials_parse_string(struct cli_credentials *credentials,
                credentials->principal = NULL;
        }
        cli_credentials_set_username(credentials, uname, obtained);
+
+       TALLOC_FREE(uname_free);
 }
 
 /**