Blame 0004-tools-remove-errx-from-adcli_read_password_func.patch

603fc1b
From 251d7d0c71226afb8e51f7bc5794a7a3164f5a20 Mon Sep 17 00:00:00 2001
603fc1b
From: Sumit Bose <sbose@redhat.com>
603fc1b
Date: Mon, 15 Apr 2019 17:59:17 +0200
603fc1b
Subject: [PATCH 4/7] tools: remove errx from adcli_read_password_func
603fc1b
603fc1b
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1588596
603fc1b
---
603fc1b
 tools/tools.c | 11 ++++++++---
603fc1b
 1 file changed, 8 insertions(+), 3 deletions(-)
603fc1b
603fc1b
diff --git a/tools/tools.c b/tools/tools.c
603fc1b
index c4e2851..bdf6d38 100644
603fc1b
--- a/tools/tools.c
603fc1b
+++ b/tools/tools.c
603fc1b
@@ -247,7 +247,9 @@ adcli_read_password_func (adcli_login_type login_type,
603fc1b
 		if (res < 0) {
603fc1b
 			if (errno == EAGAIN || errno == EINTR)
603fc1b
 				continue;
603fc1b
-			err (EFAIL, "couldn't read password from stdin");
603fc1b
+			warn ("couldn't read password from stdin");
603fc1b
+			free (buffer);
603fc1b
+			return NULL;
603fc1b
 
603fc1b
 		} else if (res == 0) {
603fc1b
 			buffer[offset] = '\0';
603fc1b
@@ -261,8 +263,11 @@ adcli_read_password_func (adcli_login_type login_type,
603fc1b
 			return buffer;
603fc1b
 
603fc1b
 		} else {
603fc1b
-			if (memchr (buffer + offset, 0, res))
603fc1b
-				errx (EUSAGE, "unsupported null character present in password");
603fc1b
+			if (memchr (buffer + offset, 0, res)) {
603fc1b
+				warnx ("unsupported null character present in password");
603fc1b
+				free (buffer);
603fc1b
+				return NULL;
603fc1b
+			}
603fc1b
 			offset += res;
603fc1b
 		}
603fc1b
 	}
603fc1b
-- 
603fc1b
2.20.1
603fc1b