Blame SOURCES/0021-Fix-race-condition-in-SEC_GetPassword.patch

0ac9f2
From a40c584691ae071e93e8adf4e5c05bcd90c68159 Mon Sep 17 00:00:00 2001
0ac9f2
From: Julien Cristau <jcristau@debian.org>
0ac9f2
Date: Sat, 6 May 2017 22:45:34 +0200
0ac9f2
Subject: [PATCH 21/29] Fix race condition in SEC_GetPassword
0ac9f2
0ac9f2
A side effect of echoOff is to discard unread input, so if we print the
0ac9f2
prompt before echoOff, the user (or process) at the other end might
0ac9f2
react to it by writing the password in between those steps, which is
0ac9f2
then discarded.  This bit me when trying to drive pesign with an expect
0ac9f2
script.
0ac9f2
0ac9f2
Signed-off-by: Julien Cristau <jcristau@debian.org>
0ac9f2
---
0ac9f2
 src/password.c | 2 +-
0ac9f2
 1 file changed, 1 insertion(+), 1 deletion(-)
0ac9f2
0ac9f2
diff --git a/src/password.c b/src/password.c
0ac9f2
index cd1c07e..d4eae0d 100644
0ac9f2
--- a/src/password.c
0ac9f2
+++ b/src/password.c
0ac9f2
@@ -71,9 +71,9 @@ static char *SEC_GetPassword(FILE *input, FILE *output, char *prompt,
0ac9f2
     for (;;) {
0ac9f2
 	/* Prompt for password */
0ac9f2
 	if (isTTY) {
0ac9f2
+	    echoOff(infd);
0ac9f2
 	    fprintf(output, "%s", prompt);
0ac9f2
             fflush (output);
0ac9f2
-	    echoOff(infd);
0ac9f2
 	}
0ac9f2
 
0ac9f2
 	fgets ( phrase, sizeof(phrase), input);
0ac9f2
-- 
0ac9f2
2.13.4
0ac9f2