mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: add missing states to the default rule and improve the error msg
There were several states missing from the default rule which catches unexpected input in a state. Update the default rule to catch all input including newlines and update its error message to include information about which state the failure occured in. Also update the comment about what to do when adding new states. While the lexer now has the "nodefault" option set, it doesn't provide as much information as the default rule does, so we prefer states to use our provided default rule. MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/569 Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
7d062917aa
commit
1a4288886b
1 changed files with 13 additions and 4 deletions
|
@ -265,7 +265,16 @@ LT_EQUAL <=
|
|||
LT <
|
||||
GT >
|
||||
|
||||
/* IF adding new state please update state_names table at eof */
|
||||
/* IF adding new state please update state_names table and default rule (just
|
||||
* above the state_names table) at the eof.
|
||||
*
|
||||
* The nodefault option is set so missing adding to the default rule isn't
|
||||
* fatal but can't take advantage of additional debug the default rule might
|
||||
* have.
|
||||
*
|
||||
* If a state is not added to the default rule it can result in the message
|
||||
* "flex scanner jammed"
|
||||
*/
|
||||
%x SUB_ID
|
||||
%x SUB_ID_WS
|
||||
%x SUB_VALUE
|
||||
|
@ -700,11 +709,11 @@ include/{WS} {
|
|||
}
|
||||
}
|
||||
|
||||
<INITIAL,SUB_ID,SUB_ID_WS,SUB_VALUE,LIST_VAL_MODE,EXTCOND_MODE,LIST_COND_VAL,LIST_COND_PAREN_VAL,LIST_COND_MODE,EXTCONDLIST_MODE,ASSIGN_MODE,NETWORK_MODE,CHANGE_PROFILE_MODE,MOUNT_MODE,DBUS_MODE,SIGNAL_MODE,PTRACE_MODE,UNIX_MODE>{
|
||||
[^\n] {
|
||||
<INITIAL,SUB_ID,SUB_ID_WS,SUB_VALUE,LIST_VAL_MODE,EXTCOND_MODE,LIST_COND_VAL,LIST_COND_PAREN_VAL,LIST_COND_MODE,EXTCONDLIST_MODE,ASSIGN_MODE,NETWORK_MODE,CHANGE_PROFILE_MODE,MOUNT_MODE,DBUS_MODE,SIGNAL_MODE,PTRACE_MODE,UNIX_MODE,RLIMIT_MODEINCLUDE,INCLUDE_EXISTS,ABI_MODE>{
|
||||
(.|\n) {
|
||||
DUMP_PREPROCESS;
|
||||
/* Something we didn't expect */
|
||||
yyerror(_("Found unexpected character: '%s'"), yytext);
|
||||
yyerror(_("Lexer found unexpected character: '%s' (0x%x) in state: %s"), yytext, yytext[0], state_names[YY_START].c_str());
|
||||
}
|
||||
}
|
||||
%%
|
||||
|
|
Loading…
Add table
Reference in a new issue