[PATCH ima-evm-utils 1/2] Strip trailing newline from password entered via prompt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The password entered via the prompt contains the trainling newline ('\n')
and therefore likely none of the passwords used for keys are 'working',
meaning using a password-protected key is likely to fail when using the
prompt. Therefore, remove the trailing newline from the password.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxx>
---
 src/evmctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/evmctl.c b/src/evmctl.c
index c35a28c..4b68091 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -2936,6 +2936,7 @@ static char *get_password(void)
 	struct termios flags, tmp_flags;
 	char *password, *pwd;
 	int passlen = 64;
+	size_t actlen;
 
 	password = malloc(passlen);
 	if (!password) {
@@ -2969,6 +2970,11 @@ static char *get_password(void)
 		return NULL;
 	}
 
+	/* strip trailing '\n' */
+	actlen = strlen(password);
+	if (actlen > 0 && password[actlen - 1] == '\n')
+		password[actlen - 1] = 0;
+
 	return password;
 }
 
-- 
2.39.2




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux