From b534617fd56d260d8d6c6c40124390ce72af476a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexandra=20H=C3=A1jkov=C3=A1?= Date: Tue, 11 May 2021 09:47:42 +0200 Subject: [PATCH] inflow.c: Do not leak tty. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In a case open() returns 0 tty might be leaked. While 0 should be stdin (and therefore is an unlikely return value from open()), it's still the case that the test should be for non-negative return values from open(). gdb/ChangeLog: 2021-05-11 Alexandra Hájková * inflow.c (new_tty): Do not leak tty. --- gdb/ChangeLog | 5 +++++ gdb/inflow.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 82131c11038..4cc0cb8794f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -247,6 +247,11 @@ * btrace.c (handle_pt_insn_events): Ignore status update enable events. +2021-05-11 Alexandra Hájková + + * inflow.c (new_tty): Do not leak tty. + + 2021-05-11 Simon Marchi * arm-tdep.c (arm_record_data_proc_misc_ld_str): Fix diff --git a/gdb/inflow.c b/gdb/inflow.c index 994c73e40ee..d241540c4cd 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -808,7 +808,7 @@ new_tty (void) systems (SVR4 for example), this may cause a SIGTTOU, so temporarily ignore SIGTTOU. */ tty = open ("/dev/tty", O_RDWR); - if (tty > 0) + if (tty >= 0) { scoped_ignore_sigttou ignore_sigttou; -- 2.30.2