conf: detect truncated lines

If the buffer filled by fgets() is full, indicating it might not contain
the whole line, abort with a fatal message.
This commit is contained in:
Miroslav Lichvar 2020-06-10 12:37:15 +02:00
parent 951f14ae06
commit ea4811b3b3

6
conf.c
View file

@ -433,7 +433,7 @@ void
CNF_ReadFile(const char *filename)
{
FILE *in;
char line[MAX_LINE_LENGTH];
char line[MAX_LINE_LENGTH + 1];
int i;
include_level++;
@ -463,6 +463,10 @@ CNF_ParseLine(const char *filename, int number, char *line)
processed_file = filename;
line_number = number;
/* Detect truncated line */
if (strlen(line) >= MAX_LINE_LENGTH)
other_parse_error("String too long");
/* Remove extra white-space and comments */
CPS_NormalizeLine(line);