less/backport-Ignore-SIGTSTP-in-secure-mode.patch

54 lines
1.2 KiB
Diff
Raw Normal View History

From e4cda4110130a4272118332f47364b1557834d1d Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Thu, 11 Mar 2021 11:45:33 -0800
Subject: [PATCH] Ignore SIGTSTP in secure mode. Also make sure variable
secure==1 when compiled with preprocessor SECURE==1.
---
main.c | 4 ++++
signal.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
index bdf6637..e429a59 100644
--- a/main.c
+++ b/main.c
@@ -75,10 +75,14 @@ main(argc, argv)
progname = *argv++;
argc--;
+#if SECURE
+ secure = 1;
+#else
secure = 0;
s = lgetenv("LESSSECURE");
if (!isnullenv(s))
secure = 1;
+#endif
#ifdef WIN32
if (getenv("HOME") == NULL)
diff --git a/signal.c b/signal.c
index 9384ff3..af4bddb 100644
--- a/signal.c
+++ b/signal.c
@@ -26,6 +26,7 @@ extern int linenums;
extern int wscroll;
extern int reading;
extern int quit_on_intr;
+extern int secure;
extern long jump_sline_fraction;
/*
@@ -153,7 +154,7 @@ init_signals(on)
(void) LSIGNAL(SIGINT, u_interrupt);
#endif
#ifdef SIGTSTP
- (void) LSIGNAL(SIGTSTP, stop);
+ (void) LSIGNAL(SIGTSTP, secure ? SIG_IGN : stop);
#endif
#ifdef SIGWINCH
(void) LSIGNAL(SIGWINCH, winch);
--
1.8.3.1