From b7b4fc51d0eadbbc94576dda75ae80098a205a24 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 9 Aug 2018 16:30:03 +0200 Subject: [PATCH] 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 --- source3/utils/pdbedit.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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) { -- 2.47.3