diff mbox series

[3/5] checkpolicy: return YYerror on invalid character

Message ID 20240311145706.34885-3-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit f4330d577052
Delegated to: Petr Lautrbach
Headers show
Series [1/5] checkpolicy/fuzz: drop redundant notdefined check | expand

Commit Message

Christian Göttsche March 11, 2024, 2:57 p.m. UTC
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>
---
Should also fix issue #67327 (leak) due to the now performed cleanup.
Also fixes issue #67272 for me, but this one might resurface.
---
 checkpolicy/policy_scan.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/checkpolicy/policy_scan.l b/checkpolicy/policy_scan.l
index 19c05a58..1926129c 100644
--- a/checkpolicy/policy_scan.l
+++ b/checkpolicy/policy_scan.l
@@ -308,7 +308,7 @@  GLBLUB				{ return(GLBLUB); }
 "]" |
 "~" |
 "*"				{ return(yytext[0]); } 
-.                               { yyerror("unrecognized character");}
+.                               { yyerror("unrecognized character"); return YYerror; }
 %%
 int yyerror(const char *msg)
 {