Skip to content

Commit 23ef7d4

Browse files
less: patch cve-2024-32487
1 parent c4c51f5 commit 23ef7d4

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

SPECS/less/CVE-2024-32487.patch

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From 007521ac3c95bc76e3d59c6dbfe75d06c8075c33 Mon Sep 17 00:00:00 2001
2+
From: Mark Nudelman <markn@greenwoodsoftware.com>
3+
Date: Thu, 11 Apr 2024 17:49:48 -0700
4+
Subject: [PATCH] Fix bug when viewing a file whose name contains a newline.
5+
6+
---
7+
filename.c | 31 +++++++++++++++++++++++++------
8+
1 file changed, 25 insertions(+), 6 deletions(-)
9+
10+
diff --git a/filename.c b/filename.c
11+
index f90e0e82..a52c6354 100644
12+
--- a/filename.c
13+
+++ b/filename.c
14+
@@ -133,6 +133,15 @@ static constant char * metachars(void)
15+
return (strchr(metachars(), c) != NULL);
16+
}
17+
18+
+/*
19+
+ * Must use quotes rather than escape char for this metachar?
20+
+ */
21+
+static int must_quote(char c)
22+
+{
23+
+ /* {{ Maybe the set of must_quote chars should be configurable? }} */
24+
+ return (c == '\n');
25+
+}
26+
+
27+
/*
28+
* Insert a backslash before each metacharacter in a string.
29+
*/
30+
@@ -164,6 +173,9 @@ public char * shell_quoten(constant char *s, size_t slen)
31+
* doesn't support escape chars. Use quotes.
32+
*/
33+
use_quotes = 1;
34+
+ } else if (must_quote(*p))
35+
+ {
36+
+ len += 3; /* open quote + char + close quote */
37+
} else
38+
{
39+
/*
40+
@@ -193,15 +205,22 @@ public char * shell_quoten(constant char *s, size_t slen)
41+
{
42+
while (*s != '\0')
43+
{
44+
- if (metachar(*s))
45+
+ if (!metachar(*s))
46+
{
47+
- /*
48+
- * Add the escape char.
49+
- */
50+
+ *p++ = *s++;
51+
+ } else if (must_quote(*s))
52+
+ {
53+
+ /* Surround the char with quotes. */
54+
+ *p++ = openquote;
55+
+ *p++ = *s++;
56+
+ *p++ = closequote;
57+
+ } else
58+
+ {
59+
+ /* Insert an escape char before the char. */
60+
strcpy(p, esc);
61+
p += esclen;
62+
+ *p++ = *s++;
63+
}
64+
- *p++ = *s++;
65+
}
66+
*p = '\0';
67+
}

SPECS/less/less.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Text file viewer
22
Name: less
33
Version: 590
4-
Release: 3%{?dist}
4+
Release: 4%{?dist}
55
License: GPLv3+ OR BSD
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -10,6 +10,7 @@ URL: https://www.greenwoodsoftware.com/less
1010
Source0: https://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
1111
Patch0: CVE-2022-46663.patch
1212
Patch1: CVE-2022-48624.patch
13+
Patch2: CVE-2024-32487.patch
1314
BuildRequires: ncurses-devel
1415
Requires: ncurses
1516

@@ -33,6 +34,9 @@ The Less package contains a text file viewer
3334
%{_mandir}/*/*
3435

3536
%changelog
37+
* Mon Apr 22 2024 Dan Streetman <ddstreet@microsoft.com> - 590-4
38+
- patch CVE-2024-32487
39+
3640
* Fri Mar 15 2024 Yash Panchal <yashpanchal@microsoft.com> - 590-3
3741
- Patch CVE-2022-48624
3842

0 commit comments

Comments
 (0)