From: Willy Tarreau Date: Thu, 25 Jun 2020 07:37:54 +0000 (+0200) Subject: BUG/MINOR: cfgparse: don't increment linenum on incomplete lines X-Git-Tag: v2.2-dev11~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40cb26f6ec8cf9d8ba54706d95df4cfed3a7b332;p=thirdparty%2Fhaproxy.git BUG/MINOR: cfgparse: don't increment linenum on incomplete lines When fgets() returns an incomplete line we must not increment linenum otherwise line numbers become incorrect. This may happen when parsing files with extremely long lines which require a realloc(). The bug has been present since unbounded line length was supported, so the fix should be backported to older branches. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 93faf4565a..191698e2b6 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1903,12 +1903,14 @@ next_line: file, linenum); err_code |= ERR_ALERT | ERR_FATAL; fatal++; + linenum--; continue; } readbytes = linesize - 1; linesize = newlinesize; thisline = newline; + linenum--; continue; }