dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
531551
From f98c5f53d4661ec22097d36f5debd195491ec3c6 Mon Sep 17 00:00:00 2001
531551
From: Karel Zak <kzak@redhat.com>
531551
Date: Thu, 15 Dec 2016 14:40:26 +0100
531551
Subject: [PATCH 101/116] more: avoid double free() on exit
531551
531551
On 'q' command more(1) calls end_it() function with _exit(). The
531551
_exit() may suspend program execution due to pending I/O on very
531551
loaded server. In this time SIGINT may be delivered due to impatient
531551
user who will press ^C.
531551
531551
And then end_it() cleanup function may be executed by signal handler
531551
too. The result is double free()...
531551
531551
Upstream: https://github.com/karelzak/util-linux/commit/0ed2a954714992938b35893b70197090a61b3b2e
531551
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1403971
531551
Signed-off-by: Karel Zak <kzak@redhat.com>
531551
---
531551
 text-utils/more.c | 8 ++++++++
531551
 1 file changed, 8 insertions(+)
531551
531551
diff --git a/text-utils/more.c b/text-utils/more.c
531551
index 0e9c2bd..f98cb14 100644
531551
--- a/text-utils/more.c
531551
+++ b/text-utils/more.c
531551
@@ -763,6 +763,14 @@ void chgwinsz(int dummy __attribute__((__unused__)))
531551
 /* Clean up terminal state and exit. Also come here if interrupt signal received */
531551
 void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__)))
531551
 {
531551
+	/* May be executed as a signal handler as well as by main process.
531551
+	 *
531551
+	 * The _exit() may wait for pending I/O for really long time, be sure
531551
+	 * that signal handler is not executed in this time to avoid double
531551
+	 * de-initialization (free() calls, etc.).
531551
+	 */
531551
+	signal(SIGINT, SIG_IGN);
531551
+
531551
 	reset_tty();
531551
 	if (clreol) {
531551
 		putchar('\r');
531551
-- 
531551
2.9.3
531551