From 40cb26f6ec8cf9d8ba54706d95df4cfed3a7b332 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 25 Jun 2020 09:37:54 +0200 Subject: [PATCH] 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. --- src/cfgparse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cfgparse.c b/src/cfgparse.c index 93faf4565..191698e2b 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; } -- 2.47.3