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, ...@@ -411,9 +411,9 @@ tokenize_file(const char *filename, FILE *file,
line_number, filename))); line_number, filename)));
/* Strip trailing linebreak from rawline */ /* Strip trailing linebreak from rawline */
while (rawline[strlen(rawline) - 1] == '\n' || lineptr = rawline + strlen(rawline) - 1;
rawline[strlen(rawline) - 1] == '\r') while (lineptr >= rawline && (*lineptr == '\n' || *lineptr == '\r'))
rawline[strlen(rawline) - 1] = '\0'; *lineptr-- = '\0';
lineptr = rawline; lineptr = rawline;
while (strlen(lineptr) > 0) 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