diff options
author | Stefan Metzmacher <metze@samba.org> | 2016-12-14 08:52:12 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2016-12-20 01:11:23 +0100 |
commit | a3f03df706f3dc8d7875226aa162154a0194f331 (patch) | |
tree | 7f506ad3aa627b62c94a665ff608522dd1d4d1f2 /auth/credentials | |
parent | 8415cca557cc556c0524cdf5ef66820d22577fb0 (diff) | |
download | samba-a3f03df706f3dc8d7875226aa162154a0194f331.tar.gz |
auth/credentials: let cli_credentials_set_password() fail if talloc_strdup() fails
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'auth/credentials')
-rw-r--r-- | auth/credentials/credentials.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/auth/credentials/credentials.c b/auth/credentials/credentials.c index 7f4c15fee18..17f4b5db6a6 100644 --- a/auth/credentials/credentials.c +++ b/auth/credentials/credentials.c @@ -339,18 +339,31 @@ _PUBLIC_ bool cli_credentials_set_password(struct cli_credentials *cred, enum credentials_obtained obtained) { if (obtained >= cred->password_obtained) { + + cred->lm_response = data_blob_null; + cred->nt_response = data_blob_null; + cred->nt_hash = NULL; + cred->password = NULL; + + cli_credentials_invalidate_ccache(cred, obtained); + cred->password_tries = 0; + + if (val == NULL) { + cred->password_obtained = obtained; + return true; + } + cred->password = talloc_strdup(cred, val); - if (cred->password) { - /* Don't print the actual password in talloc memory dumps */ - talloc_set_name_const(cred->password, "password set via cli_credentials_set_password"); + if (cred->password == NULL) { + return false; } + + /* Don't print the actual password in talloc memory dumps */ + talloc_set_name_const(cred->password, + "password set via cli_credentials_set_password"); cred->password_obtained = obtained; - cli_credentials_invalidate_ccache(cred, cred->password_obtained); - cred->nt_hash = NULL; - cred->lm_response = data_blob(NULL, 0); - cred->nt_response = data_blob(NULL, 0); return true; } |