BR 3392437: Fix diagnostic for negative value in TIMES

Issue a diagnostic and don't panic for invalid TIMES values.

Reported-by: C. Masloch <pushbx@38.de>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2017-09-27 15:22:23 -07:00
parent 230db148a3
commit 94ead27971
3 changed files with 8 additions and 3 deletions

View file

@ -603,6 +603,9 @@ int64_t assemble(int32_t segment, int64_t start, int bits, insn *instruction)
size_t blk = 0; /* Buffered I/O block size */
size_t m = 0; /* Bytes last read */
if (!t)
goto done;
fp = nasm_open_read(fname, NF_BINARY|NF_FORMAP);
if (!fp) {
nasm_error(ERR_NONFATAL, "`incbin': unable to open file `%s'",

View file

@ -515,9 +515,8 @@ restart_parse:
result->times = 1L;
} else {
result->times = value->value;
if (value->value < 0 && pass0 == 2) {
nasm_error(ERR_NONFATAL, "TIMES value %"PRId64" is negative",
value->value);
if (value->value < 0) {
nasm_error(ERR_NONFATAL|ERR_PASS2, "TIMES value %"PRId64" is negative", value->value);
result->times = 0;
}
}

3
test/timesneg.asm Normal file
View file

@ -0,0 +1,3 @@
bits 32
times -1 db 0
times -1 incbin "timesneg.asm"