From: Miroslav Lichvar Date: Wed, 10 Jun 2020 10:37:15 +0000 (+0200) Subject: conf: detect truncated lines X-Git-Tag: 4.0-pre3~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea4811b3b3086dcb62ad437f58dc7101e5d117a4;p=thirdparty%2Fchrony.git 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. --- diff --git a/conf.c b/conf.c index 810989f9..844150a7 100644 --- a/conf.c +++ b/conf.c @@ -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);