summaryrefslogtreecommitdiff
path: root/src/analysis/scan/exprs
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-08-07 00:32:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-08-07 00:32:09 (GMT)
commit1c5a0e67186def152536d9c506e2e6c3a3a265c5 (patch)
treea6f0828f39260c7a36a3055bc1b7c1435b8b5d9f /src/analysis/scan/exprs
parent293434ab6cb34f1ffb9ed2003a44d7f5aa4450cf (diff)
Reject any rule referencing itself as match condition
Diffstat (limited to 'src/analysis/scan/exprs')
-rw-r--r--src/analysis/scan/exprs/access.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/analysis/scan/exprs/access.c b/src/analysis/scan/exprs/access.c
index 1c3a880..a8f0dc9 100644
--- a/src/analysis/scan/exprs/access.c
+++ b/src/analysis/scan/exprs/access.c
@@ -428,6 +428,7 @@ static ScanReductionState g_scan_named_access_reduce(GScanNamedAccess *expr, GSc
ScanReductionState result; /* Etat synthétisé à retourner */
GRegisteredItem *resolved; /* Cible concrète obtenue */
GScanExpression *new_next; /* Nouvelle version du suivant */
+ const char *current_rule; /* Nom de la règle courante */
bool status; /* Bilan d'une autre règle */
resolved = _g_scan_named_access_prepare_reduction(expr, ctx, scope);
@@ -478,10 +479,20 @@ static ScanReductionState g_scan_named_access_reduce(GScanNamedAccess *expr, GSc
if (g_scan_context_has_rule_for_name(ctx, expr->target))
{
- status = g_scan_context_has_match_for_rule(ctx, expr->target);
+ current_rule = g_scan_scope_get_rule_name(scope);
- *out = g_scan_literal_expression_new(LVT_BOOLEAN, &status);
- result = SRS_REDUCED;
+ /* Si référence circulaire il y a... */
+ if (strcmp(current_rule, expr->target) == 0)
+ result = SRS_UNRESOLVABLE;
+
+ else
+ {
+ status = g_scan_context_has_match_for_rule(ctx, expr->target);
+
+ *out = g_scan_literal_expression_new(LVT_BOOLEAN, &status);
+ result = SRS_REDUCED;
+
+ }
}