Don't report current text in parser error messages
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user