blob: 2f23931be411999dd4de407a9e56563dedc7b0e8 (
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
38
39
40
41
42
43
44
45
46
47
48
|
From 4bae4300986d0ed3d43f92600bd291ae3d302a99 Mon Sep 17 00:00:00 2001
From: Yaswanth Reddy M <yaswanthx.reddy.munukuru@intel.com>
Date: Fri, 5 May 2023 08:55:31 +0000
Subject: [PATCH] Subject: awk: fix use after free (CVE-2022-30065)
fixes https://bugs.busybox.net/show_bug.cgi?id=14781
function old new delta
evaluate 3343 3357 +14
Signed-off-by: Yaswanth Reddy M <yaswanthx.reddy.munukuru@intel.com>
---
editors/awk.c | 3 +++
testsuite/awk.tests | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/editors/awk.c b/editors/awk.c
index 3adbca7..43a17c0 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -3094,6 +3094,9 @@ static var *evaluate(node *op, var *res)
case XC( OC_MOVE ):
debug_printf_eval("MOVE\n");
+ /* make sure that we never return a temp var */
+ if (L.v == TMPVAR0)
+ L.v = res;
/* if source is a temporary string, jusk relink it to dest */
if (R.v == TMPVAR1
&& !(R.v->type & VF_NUMBER)
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index dc2ae2e..072c8fc 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -462,5 +462,10 @@ testing "awk \"cmd\" | getline" \
"awk 'BEGIN { \"echo HELLO\" | getline; print }'" \
"HELLO\n" \
'' ''
+testing 'awk assign while test' \
+ "awk '\$1==\$1=\"foo\" {print \$1}'" \
+ "foo\n" \
+ "" \
+ "foo"
exit $FAILCOUNT
--
2.25.1
|