mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 01:57:43 +00:00
This patch fixes the parser to return an error when variable declaration
statements contain trailing commas, instead of passing them through to STDOUT. It also adds parser testcases demonstrating the issue.
This commit is contained in:
parent
83c4a5132e
commit
7ef28d9fdc
@ -380,6 +380,12 @@ LT_EQUAL <=
|
||||
return TOK_VALUE;
|
||||
}
|
||||
|
||||
{END_OF_RULE} {
|
||||
DUMP_PREPROCESS;
|
||||
yylval.id = strdup(yytext);
|
||||
yyerror(_("Variable declarations do not accept trailing commas"));
|
||||
}
|
||||
|
||||
\\\n { DUMP_PREPROCESS; current_lineno++ ; }
|
||||
|
||||
\r?\n {
|
||||
|
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_1.sd
Normal file
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_1.sd
Normal file
@ -0,0 +1,10 @@
|
||||
#=DESCRIPTION trailing commas should trigger an error
|
||||
#=EXRESULT FAIL
|
||||
|
||||
@{LIBVIRT} = libvirt,
|
||||
|
||||
/does/not/exist {
|
||||
|
||||
change_profile ->
|
||||
@{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,
|
||||
}
|
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_2.sd
Normal file
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_2.sd
Normal file
@ -0,0 +1,10 @@
|
||||
#=DESCRIPTION trailing commas should trigger an error
|
||||
#=EXRESULT FAIL
|
||||
|
||||
@{LIBVIRT} = libvirt libtriv,
|
||||
|
||||
/does/not/exist {
|
||||
|
||||
change_profile ->
|
||||
@{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,
|
||||
}
|
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_3.sd
Normal file
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_3.sd
Normal file
@ -0,0 +1,10 @@
|
||||
#=DESCRIPTION trailing commas should trigger an error
|
||||
#=EXRESULT FAIL
|
||||
|
||||
@{LIBVIRT} = libvirt, libtriv,
|
||||
|
||||
/does/not/exist {
|
||||
|
||||
change_profile ->
|
||||
@{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,
|
||||
}
|
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_4.sd
Normal file
10
parser/tst/simple_tests/vars/vars_bad_trailing_comma_4.sd
Normal file
@ -0,0 +1,10 @@
|
||||
#=DESCRIPTION trailing commas should trigger an error
|
||||
#=EXRESULT FAIL
|
||||
|
||||
@{LIBVIRT} = libvirt, libtriv
|
||||
|
||||
/does/not/exist {
|
||||
|
||||
change_profile ->
|
||||
@{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,
|
||||
}
|
10
parser/tst/simple_tests/vars/vars_simple_assignment_13.sd
Normal file
10
parser/tst/simple_tests/vars/vars_simple_assignment_13.sd
Normal file
@ -0,0 +1,10 @@
|
||||
#=DESCRIPTION quoted commas should not trigger an error
|
||||
#=EXRESULT PASS
|
||||
|
||||
@{LIBVIRT} = "libvirt,"
|
||||
|
||||
/does/not/exist {
|
||||
|
||||
change_profile ->
|
||||
@{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,
|
||||
}
|
10
parser/tst/simple_tests/vars/vars_simple_assignment_14.sd
Normal file
10
parser/tst/simple_tests/vars/vars_simple_assignment_14.sd
Normal file
@ -0,0 +1,10 @@
|
||||
#=DESCRIPTION quoted commas should not trigger an error
|
||||
#=EXRESULT PASS
|
||||
|
||||
@{LIBVIRT} = "libvirt, libtriv"
|
||||
|
||||
/does/not/exist {
|
||||
|
||||
change_profile ->
|
||||
@{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user