From d4e0a60119a575b851d6b5e6268491f432d91089 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 2 Mar 2021 15:25:34 +0100 Subject: [PATCH] Fix a parsing bug in the rules that would ignore the very first rule. See #23. --- src/parse.c | 2 +- src/parse.peg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parse.c b/src/parse.c index ffd3ce8..b020561 100644 --- a/src/parse.c +++ b/src/parse.c @@ -474,7 +474,7 @@ YY_ACTION(void) yy_1_auth_rule(yycontext *yy, char *yytext, int yyleng) } allRules[allRulesCount].type = yy->isAuthAllow ? allowRule : denyRule; if (seTotal > 0) { - if (seInfo[seTotal - 1].rulesStart == 0) { + if (seInfo[seTotal - 1].rulesStart == 0 && seInfo[seTotal - 1].rulesCount == 0) { seInfo[seTotal - 1].rulesStart = allRulesCount; } ++seInfo[seTotal - 1].rulesCount; diff --git a/src/parse.peg b/src/parse.peg index c925947..8144a45 100644 --- a/src/parse.peg +++ b/src/parse.peg @@ -98,7 +98,7 @@ auth-rule = auth-key - < pattern > } allRules[allRulesCount].type = yy->isAuthAllow ? allowRule : denyRule; if (seTotal > 0) { - if (seInfo[seTotal - 1].rulesStart == 0) { + if (seInfo[seTotal - 1].rulesStart == 0 && seInfo[seTotal - 1].rulesCount == 0) { seInfo[seTotal - 1].rulesStart = allRulesCount; } ++seInfo[seTotal - 1].rulesCount;