Blob Blame History Raw
From c334771f214e6f0cc2f13edf1032389e7bf74684 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Fri, 13 May 2016 18:05:37 +0200
Subject: [PATCH 3/3] Remove \n or \r\n from stdin password

https://bugs.freedesktop.org/show_bug.cgi?id=78448
---
 tools/tools.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/tools.c b/tools/tools.c
index 3e3435e..4b243de 100644
--- a/tools/tools.c
+++ b/tools/tools.c
@@ -250,6 +250,13 @@ adcli_read_password_func (adcli_login_type login_type,
 
 		} else if (res == 0) {
 			buffer[offset] = '\0';
+			/* remove new line character */
+			if (offset > 0 && buffer[offset - 1] == '\n') {
+				buffer[offset - 1] = '\0';
+				if (offset > 1 && buffer[offset - 2] == '\r') {
+					buffer[offset - 2] = '\0';
+				}
+			}
 			return buffer;
 
 		} else {
-- 
2.5.5