summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2017-09-27 15:22:23 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2017-09-27 15:22:23 -0700
commit94ead27971de001aea5b403130b2a94cf152ebd4 (patch)
treeb333727f7ffea0e725e4272e01838e4c7b0e07e7
parent230db148a32468468ee5f4979c6b08b0848e1e22 (diff)
downloadnasm-94ead27971de001aea5b403130b2a94cf152ebd4.tar.gz
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>
-rw-r--r--asm/assemble.c3
-rw-r--r--asm/parser.c5
-rw-r--r--test/timesneg.asm3
3 files changed, 8 insertions, 3 deletions
diff --git a/asm/assemble.c b/asm/assemble.c
index 851ea822..7869f8c1 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -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'",
diff --git a/asm/parser.c b/asm/parser.c
index d701d7fd..bbe3e588 100644
--- a/asm/parser.c
+++ b/asm/parser.c
@@ -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;
}
}
diff --git a/test/timesneg.asm b/test/timesneg.asm
new file mode 100644
index 00000000..9f16dbaa
--- /dev/null
+++ b/test/timesneg.asm
@@ -0,0 +1,3 @@
+ bits 32
+ times -1 db 0
+ times -1 incbin "timesneg.asm"