From: Tobias Brunner Date: Thu, 15 May 2014 09:55:23 +0000 (+0200) Subject: settings: Properly match } and # in include statements X-Git-Tag: 5.2.0dr4~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3dd0168f123cd9161578dd359f34dab9355857c;p=thirdparty%2Fstrongswan.git settings: Properly match } and # in include statements Found due to %option nodefault. A match for } was actually missing and # was not properly matched if it was part of an include statement on the last line of a file that did not end with a newline. --- diff --git a/src/libstrongswan/settings/settings_lexer.l b/src/libstrongswan/settings/settings_lexer.l index d9af1531d6..c6546f4643 100644 --- a/src/libstrongswan/settings/settings_lexer.l +++ b/src/libstrongswan/settings/settings_lexer.l @@ -82,12 +82,22 @@ static void include_files(parser_helper_t *ctx); { /* we allow all characters except #, } and spaces, they can be escaped */ <> | - \n|#.*\n | - [\t ] { - if (*yytext && yytext[strlen(yytext) - 1] == '\n') - { /* put the newline back to fix the line numbers */ - unput('\n'); - yy_set_bol(0); + [#}\n\t ] { + if (*yytext) + { + switch (yytext[0]) + { + case '\n': + /* put the newline back to fix the line numbers */ + unput('\n'); + yy_set_bol(0); + break; + case '#': + case '}': + /* these are parsed outside of this start condition */ + unput(yytext[0]); + break; + } } include_files(yyextra); yy_pop_state(yyscanner);