Blob Blame Raw
From 251d7d0c71226afb8e51f7bc5794a7a3164f5a20 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Mon, 15 Apr 2019 17:59:17 +0200
Subject: [PATCH 4/7] tools: remove errx from adcli_read_password_func

Related to https://bugzilla.redhat.com/show_bug.cgi?id=1588596
---
 tools/tools.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/tools.c b/tools/tools.c
index c4e2851..bdf6d38 100644
--- a/tools/tools.c
+++ b/tools/tools.c
@@ -247,7 +247,9 @@ adcli_read_password_func (adcli_login_type login_type,
 		if (res < 0) {
 			if (errno == EAGAIN || errno == EINTR)
 				continue;
-			err (EFAIL, "couldn't read password from stdin");
+			warn ("couldn't read password from stdin");
+			free (buffer);
+			return NULL;
 
 		} else if (res == 0) {
 			buffer[offset] = '\0';
@@ -261,8 +263,11 @@ adcli_read_password_func (adcli_login_type login_type,
 			return buffer;
 
 		} else {
-			if (memchr (buffer + offset, 0, res))
-				errx (EUSAGE, "unsupported null character present in password");
+			if (memchr (buffer + offset, 0, res)) {
+				warnx ("unsupported null character present in password");
+				free (buffer);
+				return NULL;
+			}
 			offset += res;
 		}
 	}
-- 
2.20.1