From 157c7b1bc43f0b1c2d121bb21f3f8eab2a2e1f40 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 4 Aug 2018 07:29:36 +0200 Subject: [PATCH] rcfile: explicitly check for disallowed keywords in included files This fixes https://savannah.gnu.org/bugs/?54441. --- src/rcfile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rcfile.c b/src/rcfile.c index 640b36aa..6f1884ab 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -928,7 +928,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) #ifdef ENABLE_COLOR /* Handle extending first... */ - if (strcasecmp(keyword, "extendsyntax") == 0) { + if (strcasecmp(keyword, "extendsyntax") == 0 && !syntax_only) { syntaxtype *sint; char *syntaxname = ptr; @@ -991,7 +991,12 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) #else ; #endif - else if (syntax_only) + else if (syntax_only && (strcasecmp(keyword, "set") == 0 || + strcasecmp(keyword, "unset") == 0 || + strcasecmp(keyword, "bind") == 0 || + strcasecmp(keyword, "unbind") == 0 || + strcasecmp(keyword, "include") == 0 || + strcasecmp(keyword, "extendsyntax") == 0)) rcfile_error(N_("Command \"%s\" not allowed in included file"), keyword); else if (strcasecmp(keyword, "include") == 0)