* Avoid possible signed overflow in decode_local_label_name
@ 2024-07-03 6:12 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2024-07-03 6:12 UTC (permalink / raw)
To: binutils
This avoids signed overflow in the "10 * x + *p - '0'" expressions.
Matches what both fb_label_name and dollar_label_name use.
* symbols.c (decode_local_label_name): Use unsigned variables.
diff --git a/gas/symbols.c b/gas/symbols.c
index b57dbfc64f4..fa3aaa37ed4 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -2185,11 +2185,11 @@ decode_local_label_name (char *s)
{
char *p;
char *symbol_decode;
- int label_number;
- int instance_number;
+ unsigned int label_number;
+ unsigned int instance_number;
const char *type;
const char *message_format;
- int lindex = 0;
+ unsigned int lindex = 0;
#ifdef LOCAL_LABEL_PREFIX
if (s[lindex] == LOCAL_LABEL_PREFIX)
@@ -2212,7 +2212,7 @@ decode_local_label_name (char *s)
for (instance_number = 0, p++; ISDIGIT (*p); ++p)
instance_number = (10 * instance_number) + *p - '0';
- message_format = _("\"%d\" (instance number %d of a %s label)");
+ message_format = _("\"%u\" (instance number %u of a %s label)");
symbol_decode = notes_alloc (strlen (message_format) + 30);
sprintf (symbol_decode, message_format, label_number, instance_number, type);
--
Alan Modra
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-07-03 6:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-03 6:12 Avoid possible signed overflow in decode_local_label_name Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).