]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Don't report current text in parser error messages
authorTobias Brunner <tobias@strongswan.org>
Mon, 10 May 2021 12:55:45 +0000 (14:55 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 11 May 2021 08:08:58 +0000 (10:08 +0200)
The values of `yytext` and `yyleng` might not be properly defined when
the error function is called (in particular if the lexer reached EOF).
While this might just cause non-printable characters in the output, it
could actually lead to a crash depending on where `yytext` points.

Closes strongswan/strongswan#346.

src/libstrongswan/settings/settings_parser.y
src/starter/parser/parser.y

index a541e6b9c945069c9d7a768a7db5228855ae343f..84106cd96cc899369a997f72d42f7b8ed6f2235d 100644 (file)
@@ -207,14 +207,7 @@ valuepart:
  */
 static void settings_parser_error(parser_helper_t *ctx, const char *s)
 {
-       char *text = settings_parser_get_text(ctx->scanner);
-       int len = settings_parser_get_leng(ctx->scanner);
-
-       if (len && text[len-1] == '\n')
-       {       /* cut off newline at the end to avoid muti-line log messages */
-               len--;
-       }
-       PARSER_DBG1(ctx, "%s [%.*s]", s, len, text);
+       PARSER_DBG1(ctx, "%s", s);
 }
 
 /**
index 09325d9758141e30b0f79d46f0f8fade647fc1fa..323da8bd21e66945019bdd5fc545383152fb6aaa 100644 (file)
@@ -212,14 +212,7 @@ value:
  */
 static void conf_parser_error(parser_helper_t *ctx, const char *s)
 {
-       char *text = conf_parser_get_text(ctx->scanner);
-       int len = conf_parser_get_leng(ctx->scanner);
-
-       if (len && text[len-1] == '\n')
-       {       /* cut off newline at the end to avoid muti-line log messages */
-               len--;
-       }
-       PARSER_DBG1(ctx, "%s [%.*s]", s, (int)len, text);
+       PARSER_DBG1(ctx, "%s", s);
 }
 
 /**