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

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