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.
This commit is contained in:
Nick Clifton
2016-12-06 15:31:14 +00:00
parent 7c2ba67e6a
commit 005304aae3
2 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,9 @@
2016-12-06 Nick Clifton <nickc@redhat.com> 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 PR gas/20896
* testsuite/gas/mmix/err-byte1.s: Adjust expected warning messages * testsuite/gas/mmix/err-byte1.s: Adjust expected warning messages
to account for patch to next_char_of_string. to account for patch to next_char_of_string.

View File

@ -3394,11 +3394,20 @@ s_space (int mult)
{ {
offsetT i; offsetT i;
if (mult == 0) /* PR 20901: Check for excessive values.
mult = 1; FIXME: 1<<10 is an arbitrary limit. Maybe use maxpagesize instead ? */
bytes = mult * exp.X_add_number; if (exp.X_add_number < 0 || exp.X_add_number > (1 << 10))
for (i = 0; i < exp.X_add_number; i++) as_bad (_("size value for s_space directive too large: %lx"),
emit_expr (&val, mult); (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 else