aboutsummaryrefslogtreecommitdiff
path: root/gas/read.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-02-16 13:11:55 +1030
committerAlan Modra <amodra@gmail.com>2022-02-16 22:05:24 +1030
commit19f7966ede4658568e273c6786e2dad73c2223e1 (patch)
tree09632187cfc3a869120841aca97c52d7d962066b /gas/read.c
parent969f6a63c0ae7779fd5eb10af25fd4ab810feef8 (diff)
downloadgdb-19f7966ede4658568e273c6786e2dad73c2223e1.zip
gdb-19f7966ede4658568e273c6786e2dad73c2223e1.tar.gz
gdb-19f7966ede4658568e273c6786e2dad73c2223e1.tar.bz2
gas local label and dollar label handling
Much of the gas source and older BFD source use "long" for function parameters and variables, when other types would be more appropriate. This patch fixes one of those cases. Dollar labels and numeric local labels do not need large numbers. Small positive itegers are usually all that is required. Due to allowing longs, it was possible for fb_label_name and dollar_label_name to overflow their buffers. * symbols.c: Delete unnecessary forward declarations. (dollar_labels, dollar_label_instances): Use unsigned int. (dollar_label_defined, dollar_label_instance): Likewise. (define_dollar_label): Likewise. (fb_low_counter, fb_labels, fb_label_instances): Likewise. (fb_label_instance_inc, fb_label_instance): Likewise. (fb_label_count, fb_label_max): Make them size_t. (dollar_label_name, fb_label_name): Rewrite using sprintf. * symbols.h (dollar_label_defined): Update prototype. (define_dollar_label, dollar_label_name): Likewise. (fb_label_instance_inc, fb_label_name): Likewise. * config/bfin-lex.l (yylex): Remove unnecessary casts. * expr.c (integer_constant): Likewise. * read.c (read_a_source_file): Limit numeric label range to int.
Diffstat (limited to 'gas/read.c')
-rw-r--r--gas/read.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gas/read.c b/gas/read.c
index f363562..fe0aff2 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -1266,7 +1266,7 @@ read_a_source_file (const char *name)
while (ISDIGIT (*input_line_pointer))
{
const long digit = *input_line_pointer - '0';
- if (temp > (LONG_MAX - digit) / 10)
+ if (temp > (INT_MAX - digit) / 10)
{
as_bad (_("local label too large near %s"), backup);
temp = -1;