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.
*/
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);
}
/**
*/
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);
}
/**