diff options
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) { |