]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cfgparse: don't increment linenum on incomplete lines
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Jun 2020 07:37:54 +0000 (09:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Jun 2020 07:43:27 +0000 (09:43 +0200)
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

index 93faf4565a0adfcaa539e6c366ddf59654f0485a..191698e2b649648def47d3bccecbaf7087561707 100644 (file)
@@ -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;
                }