mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-28 05:47:48 +00:00
Merge pull request #420 from dbrotz/disallow-null-char
Reject input that contains null characters
This commit is contained in:
@@ -269,6 +269,7 @@ YY_BUFFER_STATE yy_create_buffer(FILE *f)
|
|||||||
/* Convert all line endings to LF and spaces */
|
/* Convert all line endings to LF and spaces */
|
||||||
|
|
||||||
char *mem = pBuffer->pBuffer;
|
char *mem = pBuffer->pBuffer;
|
||||||
|
int32_t lineCount = 0;
|
||||||
|
|
||||||
while (*mem) {
|
while (*mem) {
|
||||||
if ((mem[0] == '\\') && (mem[1] == '\"' || mem[1] == '\\')) {
|
if ((mem[0] == '\\') && (mem[1] == '\"' || mem[1] == '\\')) {
|
||||||
@@ -279,15 +280,22 @@ YY_BUFFER_STATE yy_create_buffer(FILE *f)
|
|||||||
|| ((mem[0] == '\r') && (mem[1] == '\n'))) {
|
|| ((mem[0] == '\r') && (mem[1] == '\n'))) {
|
||||||
*mem++ = ' ';
|
*mem++ = ' ';
|
||||||
*mem++ = '\n';
|
*mem++ = '\n';
|
||||||
|
lineCount++;
|
||||||
/* LF and CR */
|
/* LF and CR */
|
||||||
} else if ((mem[0] == '\n') || (mem[0] == '\r')) {
|
} else if ((mem[0] == '\n') || (mem[0] == '\r')) {
|
||||||
*mem++ = '\n';
|
*mem++ = '\n';
|
||||||
|
lineCount++;
|
||||||
} else {
|
} else {
|
||||||
mem++;
|
mem++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mem != pBuffer->pBuffer + size) {
|
||||||
|
nLineNo = lineCount + 1;
|
||||||
|
fatalerror("Found null character");
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove comments */
|
/* Remove comments */
|
||||||
|
|
||||||
mem = pBuffer->pBuffer;
|
mem = pBuffer->pBuffer;
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
ERROR: null-in-macro.asm(1):
|
ERROR: null-in-macro.asm(2):
|
||||||
Unterminated MACRO definition.
|
Found null character
|
||||||
|
|||||||
Reference in New Issue
Block a user