]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cfgparse: Support configurations without newline at EOF
authorTim Duesterhus <tim@bastelstu.be>
Mon, 22 Jun 2020 20:57:44 +0000 (22:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 23 Jun 2020 03:14:36 +0000 (05:14 +0200)
Fix parsing of configurations if the configuration file does not end with
an LF.

This patch fixes GitHub issue #704. It's a regression in
9e1758efbd68c8b1d27e17e2abe4444e110f3ebe which is 2.2 specific. No backport
needed.

src/cfgparse.c

index fdbf3a4066dc5000328870a8cb8ee99093ce8a1d..4ccca14d2b3d85155ce970db60bb7a26250c5e44 100644 (file)
@@ -1905,8 +1905,10 @@ next_line:
 
                readbytes = 0;
 
-               /* kill trailing LF */
-               *(end - 1) = 0;
+               if (*(end-1) == '\n') {
+                       /* kill trailing LF */
+                       *(end - 1) = 0;
+               }
 
                /* skip leading spaces */
                while (isspace((unsigned char)*line))