mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge from trunk revision 1571: 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. Nominated-By: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
7714b62889
commit
d7e06b79bb
7 changed files with 66 additions and 0 deletions
|
@ -377,6 +377,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…
Add table
Reference in a new issue