2
0
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:
Steve Beattie 2010-11-19 01:42:04 -08:00
parent 83c4a5132e
commit 7ef28d9fdc
7 changed files with 66 additions and 0 deletions

View File

@ -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 {

View 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]*,
}

View 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]*,
}

View 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]*,
}

View 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]*,
}

View 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]*,
}

View 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]*,
}