From 70f58997f47e8ed48fe9ec517d80a32c8d575bc0 Mon Sep 17 00:00:00 2001 From: Tim Duesterhus Date: Mon, 22 Jun 2020 22:57:44 +0200 Subject: [PATCH] BUG/MINOR: cfgparse: Support configurations without newline at EOF 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index fdbf3a4066..4ccca14d2b 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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)) -- 2.39.5