Commit 3a5d0c55 authored by Noah Misch's avatar Noah Misch

Avoid reading below the start of a stack variable in tokenize_file().

We would wrongly overwrite the prior stack byte if it happened to
contain '\n' or '\r'.  New in 9.3, so no back-patch.
parent 813895e4
......@@ -411,9 +411,9 @@ tokenize_file(const char *filename, FILE *file,
line_number, filename)));
/* Strip trailing linebreak from rawline */
while (rawline[strlen(rawline) - 1] == '\n' ||
rawline[strlen(rawline) - 1] == '\r')
rawline[strlen(rawline) - 1] = '\0';
lineptr = rawline + strlen(rawline) - 1;
while (lineptr >= rawline && (*lineptr == '\n' || *lineptr == '\r'))
*lineptr-- = '\0';
lineptr = rawline;
while (strlen(lineptr) > 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment