]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libiberty d_compact_number signed integer overflow
authorAlan Modra <amodra@gmail.com>
Wed, 1 Jul 2026 01:27:51 +0000 (10:57 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 1 Jul 2026 01:27:51 +0000 (10:57 +0930)
https://lists.gnu.org/archive/html/bug-binutils/2026-06/msg00189.html
Fix this by doing the addition in unsigned arithmetic.

libiberty/cp-demangle.c

index 5f08ef8946af8e8d1cc6c685f8eabf491efd91a8..ab122fc388d2732dbf65bf037d117282efde9a6a 100644 (file)
@@ -3266,7 +3266,7 @@ d_compact_number (struct d_info *di)
   else if (d_peek_char (di) == 'n')
     return -1;
   else
-    num = d_number (di) + 1;
+    num = d_number (di) + 1u;
 
   if (num < 0 || ! d_check_char (di, '_'))
     return -1;