From b75005da2cebe28225be3d6f6576ddca8b869f86 Mon Sep 17 00:00:00 2001 From: liweigang Date: Mon, 19 Feb 2024 13:58:41 +0800 Subject: [PATCH] fix CVE-2022-48624 Signed-off-by: liweigang (cherry picked from commit ac4dc1c9774d0a7dcb4c1090f7be9c564f21f7ce) --- ...te-filenames-when-invoking-LESSCLOSE.patch | 38 +++++++++++++++++++ less.spec | 6 ++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backport-Shell-quote-filenames-when-invoking-LESSCLOSE.patch diff --git a/backport-Shell-quote-filenames-when-invoking-LESSCLOSE.patch b/backport-Shell-quote-filenames-when-invoking-LESSCLOSE.patch new file mode 100644 index 0000000..fdd4244 --- /dev/null +++ b/backport-Shell-quote-filenames-when-invoking-LESSCLOSE.patch @@ -0,0 +1,38 @@ +From c6ac6de49698be84d264a0c4c0c40bb870b10144 Mon Sep 17 00:00:00 2001 +From: Mark Nudelman +Date: Sat, 25 Jun 2022 11:54:43 -0700 +Subject: [PATCH] Shell-quote filenames when invoking LESSCLOSE. + +--- + filename.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/filename.c b/filename.c +index 5824e385..dff20c08 100644 +--- a/filename.c ++++ b/filename.c +@@ -972,6 +972,8 @@ close_altfile(altfilename, filename) + { + #if HAVE_POPEN + char *lessclose; ++ char *qfilename; ++ char *qaltfilename; + FILE *fd; + char *cmd; + int len; +@@ -986,9 +988,13 @@ close_altfile(altfilename, filename) + error("LESSCLOSE ignored; must contain no more than 2 %%s", NULL_PARG); + return; + } +- len = (int) (strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2); ++ qfilename = shell_quote(filename); ++ qaltfilename = shell_quote(altfilename); ++ len = (int) (strlen(lessclose) + strlen(qfilename) + strlen(qaltfilename) + 2); + cmd = (char *) ecalloc(len, sizeof(char)); +- SNPRINTF2(cmd, len, lessclose, filename, altfilename); ++ SNPRINTF2(cmd, len, lessclose, qfilename, qaltfilename); ++ free(qaltfilename); ++ free(qfilename); + fd = shellcmd(cmd); + free(cmd); + if (fd != NULL) diff --git a/less.spec b/less.spec index 03ca6f1..34baca5 100644 --- a/less.spec +++ b/less.spec @@ -1,6 +1,6 @@ Name: less Version: 590 -Release: 2 +Release: 3 Summary: Less is a pager that displays text files. License: GPLv3+ or BSD URL: http://www.greenwoodsoftware.com/less @@ -8,6 +8,7 @@ Source0: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz Patch0: less-394-time.patch Patch1: less-475-fsync.patch Patch2: backport-End-OSC8-hyperlink-on-invalid-embedded-escape-sequen.patch +Patch3: backport-Shell-quote-filenames-when-invoking-LESSCLOSE.patch BuildRequires: git gcc make ncurses-devel autoconf automake libtool @@ -46,6 +47,9 @@ autoreconf -ivf %{_mandir}/man1/* %changelog +* Mon Feb 19 2024 liweigang - 590-3 +- fix CVE-2022-48624 + * Thu Feb 16 2023 hongjinghao - 590-2 - fix CVE-2022-46663 -- Gitee