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/passwd_util.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/passwd_util.c')
-rw-r--r-- | source3/utils/passwd_util.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source3/utils/passwd_util.c b/source3/utils/passwd_util.c index 5716c17a3a..4884d63bf1 100644 --- a/source3/utils/passwd_util.c +++ b/source3/utils/passwd_util.c @@ -42,11 +42,12 @@ char *stdin_new_passwd( void) * the newline that ends the password, then replace the newline with * a null terminator. */ - if ( fgets(new_pw, sizeof(new_pw), stdin) != NULL) { - if ((len = strlen(new_pw)) > 0) { - if(new_pw[len-1] == '\n') - new_pw[len - 1] = 0; - } + if ( fgets(new_pw, sizeof(new_pw), stdin) == NULL) { + return NULL; + } + if ((len = strlen(new_pw)) > 0) { + if(new_pw[len-1] == '\n') + new_pw[len - 1] = 0; } return(new_pw); } @@ -64,6 +65,9 @@ char *get_pass( const char *prompt, bool stdin_get) if (stdin_get) { p = stdin_new_passwd(); + if (p == NULL) { + return NULL; + } } else { rc = samba_getpass(prompt, pwd, sizeof(pwd), false, false); if (rc < 0) { |