summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox/0001-awk.c-fix-CVE-2023-42366-bug-15874.patch
blob: 282c2fde5a54f7608d6ad06a2b83aed6ed94111b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 8542236894a8d5f7393327117bc7f64787444efc Mon Sep 17 00:00:00 2001
From: Valery Ushakov <uwe@stderr.spb.ru>
Date: Wed, 24 Jan 2024 22:24:41 +0300
Subject: [PATCH] awk.c: fix CVE-2023-42366 (bug #15874)

Make sure we don't read past the end of the string in next_token()
when backslash is the last character in an (invalid) regexp.
a fix and issue reported in bugzilla

https://bugs.busybox.net/show_bug.cgi?id=15874

Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2024-May/090766.html]

CVE: CVE-2023-42366
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 editors/awk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/editors/awk.c b/editors/awk.c
index f320d8c..a53b193 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1168,9 +1168,11 @@ static uint32_t next_token(uint32_t expected)
 					s[-1] = bb_process_escape_sequence((const char **)&pp);
 					if (*p == '\\')
 						*s++ = '\\';
-					if (pp == p)
+					if (pp == p) {
+						if (*p == '\0')
+							syntax_error(EMSG_UNEXP_EOS);
 						*s++ = *p++;
-					else
+					} else
 						p = pp;
 				}
 			}