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

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