jam: jcache: read_file(): fail when encountering too long lines

For its input files jam uses a buffer of 512 chars for fgets(). Lines
would therefore be split silently after that length, which could lead to
"interesting" issues. Now we fail to prevent the situation from going
unnoticed.
This commit is contained in:
Ingo Weinhold 2013-07-25 23:00:31 +02:00
parent 502f1ff979
commit 531916daa2

View File

@ -444,6 +444,11 @@ read_file(const char *filename, string_list* list)
len++;
line[len] = '\0';
}
if ((size_t)len + 1 == sizeof(buffer)) {
fprintf(stderr, "error: %s:%d: line too long!\n", filename,
list->count + 1);
exit(1);
}
// copy it
string = (char*)malloc(len + 1);
if (string) {