diff options
| author | Jeremy Allison <jra@samba.org> | 2013-12-12 09:37:25 -0800 |
|---|---|---|
| committer | Volker Lendecke <vl@samba.org> | 2013-12-16 15:17:58 +0100 |
| commit | ef5a3bedab74420baf0c653cf8e304fe6c2a13b4 (patch) | |
| tree | 5b76c9b7161a13af754deaa9cdf137b6162ab5f8 /source3/utils/smbpasswd.c | |
| parent | 5ac5e335e0596583e11a750d31f133da3fad8fd4 (diff) | |
| download | samba-ef5a3bedab74420baf0c653cf8e304fe6c2a13b4.tar.gz samba-ef5a3bedab74420baf0c653cf8e304fe6c2a13b4.tar.xz samba-ef5a3bedab74420baf0c653cf8e304fe6c2a13b4.zip | |
s3: smbpasswd - fix crashes on invalid input.
get_pass can return NULL on error. Ensure that
this is always the case and fix all callers to cope
(some already did).
Reported by Joonas Kuorilehto <joneskoo@codenomicon.com>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10320
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Dec 16 15:17:58 CET 2013 on sn-devel-104
Diffstat (limited to 'source3/utils/smbpasswd.c')
| -rw-r--r-- | source3/utils/smbpasswd.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index d93261eade..67780ff7cd 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -217,11 +217,17 @@ static char *prompt_for_new_password(bool stdin_get) ZERO_ARRAY(new_pw); p = get_pass("New SMB password:", stdin_get); + if (p == NULL) { + return NULL; + } fstrcpy(new_pw, p); SAFE_FREE(p); p = get_pass("Retype new SMB password:", stdin_get); + if (p == NULL) { + return NULL; + } if (strcmp(p, new_pw)) { fprintf(stderr, "Mismatch - password unchanged.\n"); @@ -311,6 +317,10 @@ static int process_root(int local_flags) printf("Setting stored password for \"%s\" in secrets.tdb\n", ldap_admin_dn); if ( ! *ldap_secret ) { new_passwd = prompt_for_new_password(stdin_passwd_get); + if (new_passwd == NULL) { + fprintf(stderr, "Failed to read new password!\n"); + exit(1); + } fstrcpy(ldap_secret, new_passwd); } if (!store_ldap_admin_pw(ldap_secret)) { @@ -538,6 +548,10 @@ static int process_nonroot(int local_flags) if (remote_machine != NULL) { old_pw = get_pass("Old SMB password:",stdin_passwd_get); + if (old_pw == NULL) { + fprintf(stderr, "Unable to get old password.\n"); + exit(1); + } } if (!new_passwd) { |
