From: Andreas Schneider Date: Thu, 9 Aug 2018 14:30:03 +0000 (+0200) Subject: s3:utils: Do not leak memory in new_user() X-Git-Tag: ldb-1.5.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7b4fc51d0eadbbc94576dda75ae80098a205a24;p=thirdparty%2Fsamba.git s3:utils: Do not leak memory in new_user() Found by covscan. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13567 Pair-Programmed-With: Justin Stephenson Signed-off-by: Andreas Schneider Signed-off-by: Justin Stephenson Reviewed-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index a353bae7c4e..5c947e2fbde 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -750,7 +750,7 @@ static int new_user(const char *username, const char *fullname, NTSTATUS status; struct dom_sid u_sid; int flags; - int ret; + int ret = -1; tosctx = talloc_tos(); if (!tosctx) { @@ -766,10 +766,14 @@ static int new_user(const char *username, const char *fullname, } pwd1 = get_pass( "new password:", stdin_get); + if (pwd1 == NULL) { + fprintf(stderr, "Failed to read passwords.\n"); + goto done; + } pwd2 = get_pass( "retype new password:", stdin_get); - if (!pwd1 || !pwd2) { + if (pwd2 == NULL) { fprintf(stderr, "Failed to read passwords.\n"); - return -1; + goto done; } ret = strcmp(pwd1, pwd2); if (ret != 0) {