Blame SOURCES/0001-Check-if-we-are-on-tty-before-initializing-curses.patch

498c49
From a3a81549ffb787410a694b6e29de6638588eaf88 Mon Sep 17 00:00:00 2001
498c49
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
498c49
Date: Fri, 14 Feb 2014 12:58:38 +0100
498c49
Subject: [PATCH] Check if we are on tty before initializing curses.
498c49
498c49
* pinentry/pinentry-curses.c (dialog_run): Check stant stdin and stout
498c49
are connected to ttys.
498c49
498c49
--
498c49
498c49
When we did not have a ttyname we just used stdin/out without checking
498c49
if it's a proper TTY or a pipe. In some cases this can cause endless
498c49
loop or escape seqeunces on the terminal.
498c49
498c49
This commit changes behaviour so that if stdin/out is not tty and no
498c49
ttyname is specified we error-out with errno set to ENOTTY
498c49
---
498c49
 pinentry/pinentry-curses.c | 5 +++++
498c49
 1 file changed, 5 insertions(+)
498c49
498c49
diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
498c49
index 585059f..5482c15 100644
498c49
--- a/pinentry/pinentry-curses.c
498c49
+++ b/pinentry/pinentry-curses.c
498c49
@@ -746,6 +746,11 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
498c49
     {
498c49
       if (!init_screen)
498c49
 	{
498c49
+          if (!(isatty(fileno(stdin)) && isatty(fileno(stdout))))
498c49
+            {
498c49
+              errno = ENOTTY;
498c49
+              return -1;
498c49
+            }
498c49
 	  init_screen = 1;
498c49
 	  initscr ();
498c49
 	}
498c49
-- 
498c49
2.5.0
498c49