aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-12-06 15:31:14 +0000
committerNick Clifton <nickc@redhat.com>2016-12-06 15:31:14 +0000
commit005304aae36522a90bbe169faea36db559d0f3d6 (patch)
tree5502c5133c6bc2c8fc5dff3fec81fa0cf4741f2c /gas
parent7c2ba67e6ab10879968c938aefd4d0d0b4ce79bc (diff)
downloadgdb-005304aae36522a90bbe169faea36db559d0f3d6.zip
gdb-005304aae36522a90bbe169faea36db559d0f3d6.tar.gz
gdb-005304aae36522a90bbe169faea36db559d0f3d6.tar.bz2
Stop the assembler from running out of memory when asked to generate a huge number of spaces.
PR gas/20901 * read.c (s_space): Place an upper limit on the number of spaces generated.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog4
-rw-r--r--gas/read.c19
2 files changed, 18 insertions, 5 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index bb6beb8..781e975 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,9 @@
2016-12-06 Nick Clifton <nickc@redhat.com>
+ PR gas/20901
+ * read.c (s_space): Place an upper limit on the number of spaces
+ generated.
+
PR gas/20896
* testsuite/gas/mmix/err-byte1.s: Adjust expected warning messages
to account for patch to next_char_of_string.
diff --git a/gas/read.c b/gas/read.c
index 0cc0d20..08b8846 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3394,11 +3394,20 @@ s_space (int mult)
{
offsetT i;
- if (mult == 0)
- mult = 1;
- bytes = mult * exp.X_add_number;
- for (i = 0; i < exp.X_add_number; i++)
- emit_expr (&val, mult);
+ /* PR 20901: Check for excessive values.
+ FIXME: 1<<10 is an arbitrary limit. Maybe use maxpagesize instead ? */
+ if (exp.X_add_number < 0 || exp.X_add_number > (1 << 10))
+ as_bad (_("size value for s_space directive too large: %lx"),
+ (long) exp.X_add_number);
+ else
+ {
+ if (mult == 0)
+ mult = 1;
+ bytes = mult * exp.X_add_number;
+
+ for (i = 0; i < exp.X_add_number; i++)
+ emit_expr (&val, mult);
+ }
}
}
else