summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0018-CVE-2021-3530.patch
blob: e569a6bc47c03c5f0201b955dc11e448e1adf3fa (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 999566402e3d7c69032bbf47e28b44fc0926fe62 Mon Sep 17 00:00:00 2001
From: Christopher Wellons <wellons@nullprogram.com>
Date: Sun, 18 Jul 2021 16:57:19 -0400
Subject: [PATCH] Change "uint" to "unsigned"

This fixes a defect introduced in 25162c795. The "uint" type has not
been explicitly defined here on mingw, causing compilation to fail.

On linux we have this in /usr/include/sys/types.h

/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;

So it's easy to see how such bugs can creep in.

	* rust-demangle.c (struct rust_demangler): Change type of
	"recursion" to unsigned.
	(RUST_NO_RECURSION_LIMIT): Similarly in cast.

CVE: CVE-2021-3530
Upstream-Status: Backport[https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=999566402e3]
Signed-off-by: Pgowda <pgowda.cve@gmail.com>

---
 libiberty/ChangeLog       | 6 ++++++
 libiberty/rust-demangle.c | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 8e39fd28eba..3f749455f05 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,9 @@
+2021-07-19  Christopher Wellons  <wellons@nullprogram.com>
+
+	* rust-demangle.c (struct rust_demangler): Change type of
+	"recursion" to unsigned.
+	(RUST_NO_RECURSION_LIMIT): Similarly in cast.
+
 2021-07-15  Nick Clifton  <nickc@redhat.com>
 
 	PR 99935
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
index df09b7b8fdd..ac1eb8eb02c 100644
--- a/libiberty/rust-demangle.c
+++ b/libiberty/rust-demangle.c
@@ -75,10 +75,10 @@ struct rust_demangler
   int version;
 
   /* Recursion depth.  */
-  uint recursion;
+  unsigned recursion;
   /* Maximum number of times demangle_path may be called recursively.  */
 #define RUST_MAX_RECURSION_COUNT  1024
-#define RUST_NO_RECURSION_LIMIT   ((uint) -1)
+#define RUST_NO_RECURSION_LIMIT   ((unsigned) -1)
 
   uint64_t bound_lifetime_depth;
 };
-- 
2.27.0