ref: 7b592eff8a8db5b3475e9aeb7d8a53b7b2086124
parent: 4be81d9ffd1751508345227ae1fefcde256e64a2
parent: c5e8e4ff83c70ddf32f00bfa69f0d4f918af3c15
author: Eldred Habert <[email protected]>
date: Sat Sep 21 22:43:06 EDT 2019
Merge pull request #420 from dbrotz/disallow-null-char Reject input that contains null characters
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -269,6 +269,7 @@
/* Convert all line endings to LF and spaces */
char *mem = pBuffer->pBuffer;
+ int32_t lineCount = 0;
while (*mem) {
if ((mem[0] == '\\') && (mem[1] == '\"' || mem[1] == '\\')) {
@@ -279,13 +280,20 @@
|| ((mem[0] == '\r') && (mem[1] == '\n'))) {
*mem++ = ' ';
*mem++ = '\n';
+ lineCount++;
/* LF and CR */
} else if ((mem[0] == '\n') || (mem[0] == '\r')) {
*mem++ = '\n';
+ lineCount++;
} else {
mem++;
}
}
+ }
+
+ if (mem != pBuffer->pBuffer + size) {
+ nLineNo = lineCount + 1;
+ fatalerror("Found null character");
}
/* Remove comments */
--- a/test/asm/null-in-macro.out
+++ b/test/asm/null-in-macro.out
@@ -1,2 +1,2 @@
-ERROR: null-in-macro.asm(1):
- Unterminated MACRO definition.
+ERROR: null-in-macro.asm(2):
+ Found null character