libiberty d_compact_number signed integer overflow

Message ID akRw-8BLQ-FkUM9O@squeak.grove.modra.org
State New
Headers
Series libiberty d_compact_number signed integer overflow |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply

Commit Message

Alan Modra July 1, 2026, 1:44 a.m. UTC
  https://lists.gnu.org/archive/html/bug-binutils/2026-06/msg00189.html
Fix this by doing the addition in unsigned arithmetic.

Applying to binutils and gcc as obvious.
  

Patch

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 5f08ef8946a..ab122fc388d 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -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;