checkpolicy: return YYerror on invalid character

Inform bison about an invalid character by returning YYerror, so the
parser can cleanup internal state and return the failure via yyparse().
Currently the error is only observable via the global variable
policydb_errors, which needs to be checked separately.

Reported-by: oss-fuzz (issue #67270)
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Christian Göttsche 2024-03-11 15:57:04 +01:00 committed by James Carter
parent 0e1e30db35
commit f4330d5770
1 changed files with 1 additions and 1 deletions

View File

@ -308,7 +308,7 @@ GLBLUB { return(GLBLUB); }
"]" | "]" |
"~" | "~" |
"*" { return(yytext[0]); } "*" { return(yytext[0]); }
. { yyerror("unrecognized character");} . { yyerror("unrecognized character"); return YYerror; }
%% %%
int yyerror(const char *msg) int yyerror(const char *msg)
{ {