summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/nasm/nasm/CVE-2022-44370.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/nasm/nasm/CVE-2022-44370.patch')
-rw-r--r--meta/recipes-devtools/nasm/nasm/CVE-2022-44370.patch104
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/recipes-devtools/nasm/nasm/CVE-2022-44370.patch b/meta/recipes-devtools/nasm/nasm/CVE-2022-44370.patch
new file mode 100644
index 0000000000..1bd49c9fd9
--- /dev/null
+++ b/meta/recipes-devtools/nasm/nasm/CVE-2022-44370.patch
@@ -0,0 +1,104 @@
1From b37677f7e40276bd8f504584bcba2c092f1146a8 Mon Sep 17 00:00:00 2001
2From: "H. Peter Anvin" <hpa@zytor.com>
3Date: Mon, 7 Nov 2022 10:26:03 -0800
4Subject: [PATCH] quote_for_pmake: fix counter underrun resulting in segfault
5
6while (nbs--) { ... } ends with nbs == -1. Rather than a minimal fix,
7introduce mempset() to make these kinds of errors less likely in the
8future.
9
10Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392815
11Reported-by: <13579and24680@gmail.com>
12Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13
14Upstream-Status: Backport
15CVE: CVE-2022-4437
16
17Reference to upstream patch:
18[https://github.com/netwide-assembler/nasm/commit/2d4e6952417ec6f08b6f135d2b5d0e19b7dae30d]
19
20Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
21---
22 asm/nasm.c | 12 +++++-------
23 configure.ac | 1 +
24 include/compiler.h | 7 +++++++
25 3 files changed, 13 insertions(+), 7 deletions(-)
26
27diff --git a/asm/nasm.c b/asm/nasm.c
28index 7a7f8b4..675cff4 100644
29--- a/asm/nasm.c
30+++ b/asm/nasm.c
31@@ -1,6 +1,6 @@
32 /* ----------------------------------------------------------------------- *
33 *
34- * Copyright 1996-2020 The NASM Authors - All Rights Reserved
35+ * Copyright 1996-2022 The NASM Authors - All Rights Reserved
36 * See the file AUTHORS included with the NASM distribution for
37 * the specific copyright holders.
38 *
39@@ -814,8 +814,7 @@ static char *quote_for_pmake(const char *str)
40 }
41
42 /* Convert N backslashes at the end of filename to 2N backslashes */
43- if (nbs)
44- n += nbs;
45+ n += nbs;
46
47 os = q = nasm_malloc(n);
48
49@@ -824,10 +823,10 @@ static char *quote_for_pmake(const char *str)
50 switch (*p) {
51 case ' ':
52 case '\t':
53- while (nbs--)
54- *q++ = '\\';
55+ q = mempset(q, '\\', nbs);
56 *q++ = '\\';
57 *q++ = *p;
58+ nbs = 0;
59 break;
60 case '$':
61 *q++ = *p;
62@@ -849,9 +848,8 @@ static char *quote_for_pmake(const char *str)
63 break;
64 }
65 }
66- while (nbs--)
67- *q++ = '\\';
68
69+ q = mempset(q, '\\', nbs);
70 *q = '\0';
71
72 return os;
73diff --git a/configure.ac b/configure.ac
74index 39680b1..940ebe2 100644
75--- a/configure.ac
76+++ b/configure.ac
77@@ -199,6 +199,7 @@ AC_CHECK_FUNCS(strrchrnul)
78 AC_CHECK_FUNCS(iscntrl)
79 AC_CHECK_FUNCS(isascii)
80 AC_CHECK_FUNCS(mempcpy)
81+AC_CHECK_FUNCS(mempset)
82
83 AC_CHECK_FUNCS(getuid)
84 AC_CHECK_FUNCS(getgid)
85diff --git a/include/compiler.h b/include/compiler.h
86index db3d6d6..b64da6a 100644
87--- a/include/compiler.h
88+++ b/include/compiler.h
89@@ -256,6 +256,13 @@ static inline void *mempcpy(void *dst, const void *src, size_t n)
90 }
91 #endif
92
93+#ifndef HAVE_MEMPSET
94+static inline void *mempset(void *dst, int c, size_t n)
95+{
96+ return (char *)memset(dst, c, n) + n;
97+}
98+#endif
99+
100 /*
101 * Hack to support external-linkage inline functions
102 */
103--
1042.40.0