diff --git a/SOURCES/less-458-CVE-2024-32487.patch b/SOURCES/less-458-CVE-2024-32487.patch new file mode 100644 index 0000000..e6ba0e8 --- /dev/null +++ b/SOURCES/less-458-CVE-2024-32487.patch @@ -0,0 +1,65 @@ +Patch backported from: + +commit 007521ac3c95bc76e3d59c6dbfe75d06c8075c33 +Author: Mark Nudelman +Date: Thu Apr 11 17:49:48 2024 -0700 + + Fix bug when viewing a file whose name contains a newline. + +diff -up less-643/filename.c.cve-2024-32487 less-643/filename.c +--- less-643/filename.c.cve-2024-32487 2023-07-21 00:43:14.000000000 +0200 ++++ less-643/filename.c 2024-04-23 10:24:17.347269703 +0200 +@@ -128,6 +128,15 @@ static char * metachars(void) + } + + /* ++ * Must use quotes rather than escape char for this metachar? ++ */ ++static int must_quote(char c) ++{ ++ /* {{ Maybe the set of must_quote chars should be configurable? }} */ ++ return (c == '\n'); ++} ++ ++/* + * Insert a backslash before each metacharacter in a string. + */ + public char * +@@ -164,6 +173,9 @@ public char * shell_quote(char *s) + * doesn't support escape chars. Use quotes. + */ + use_quotes = 1; ++ } else if (must_quote(*p)) ++ { ++ len += 3; /* open quote + char + close quote */ + } else + { + /* +@@ -193,15 +205,22 @@ public char * shell_quote(char *s) + { + while (*s != '\0') + { +- if (metachar(*s)) ++ if (!metachar(*s)) + { +- /* +- * Add the escape char. +- */ ++ *p++ = *s++; ++ } else if (must_quote(*s)) ++ { ++ /* Surround the char with quotes. */ ++ *p++ = openquote; ++ *p++ = *s++; ++ *p++ = closequote; ++ } else ++ { ++ /* Insert an escape char before the char. */ + strcpy(p, esc); + p += esclen; ++ *p++ = *s++; + } +- *p++ = *s++; + } + *p = '\0'; + } diff --git a/SPECS/less.spec b/SPECS/less.spec index d2f365c..2254a31 100644 --- a/SPECS/less.spec +++ b/SPECS/less.spec @@ -1,7 +1,7 @@ Summary: A text file browser similar to more, but better Name: less Version: 458 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv3+ Group: Applications/Text Source: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz @@ -19,6 +19,7 @@ Patch9: less-458-less-filters-man.patch Patch10: less-458-lesskey-usage.patch Patch11: less-458-old-bot-in-help.patch Patch12: less-458-use-backslash.patch +Patch13: less-458-CVE-2024-32487.patch URL: http://www.greenwoodsoftware.com/less/ Requires: groff-base BuildRequires: ncurses-devel @@ -47,6 +48,7 @@ files, and you'll use it frequently. %patch10 -p1 -b .lesskey-usage %patch11 -p1 -b .oldbothelp %patch12 -p2 -b .use-backslash +%patch13 -p1 -b .CVE-2024-32487 autoreconf chmod -R a+w * @@ -76,6 +78,10 @@ ls -la $RPM_BUILD_ROOT/etc/profile.d rm -rf $RPM_BUILD_ROOT %changelog +* Tue Apr 23 2024 Matej Mužila - 458-10 +- Fix CVE-2024-32487 +- Resolves: RHEL-32802 + * Thu May 21 2015 Jozef Mlich - 458-9 - The --use-backslash option documented in the man page was missing from online help for less.