[PATCH] conffile: clear invalid section on unmatched quote

xuchenchen <xu18736995897-9Onoh4P/[email protected]> Tue, 4 Aug 2026 20:14:01 +0800
Newsgroups gmane.linux.nfs
Message-ID <[email protected]>
From: xuchenchen <xuchenchen-UOlijcLmZ/[email protected]>

When a section header contains an opening quote without a matching closing quote, conf_parse_line() leaves the newly allocated section name active. As a result, assignments following the malformed header can be added to that invalid section even though the diagnostic says they will be ignored until the next section.

Free and clear the section name before returning so subsequent assignments are ignored as intended.

Signed-off-by: xuchenchen <xuchenchen-UOlijcLmZ/[email protected]>
---
 support/nfs/conffile.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 8d242c2f..08d45f00 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -364,6 +364,8 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
 			xlog_warn("config error at %s:%d: "
 				  "non-matched '\"', ignoring until next section",
 				filename, lineno);
+			free(*section);
+			*section = NULL;
 			return;
 		}
 		*ptr = '\0';
-- 
2.47.3