diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-08-07 00:32:09 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-08-07 00:32:09 (GMT) |
commit | 1c5a0e67186def152536d9c506e2e6c3a3a265c5 (patch) | |
tree | a6f0828f39260c7a36a3055bc1b7c1435b8b5d9f /src/analysis/scan/context.c | |
parent | 293434ab6cb34f1ffb9ed2003a44d7f5aa4450cf (diff) |
Reject any rule referencing itself as match condition
Diffstat (limited to 'src/analysis/scan/context.c')
-rw-r--r-- | src/analysis/scan/context.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/analysis/scan/context.c b/src/analysis/scan/context.c index 1f9c38e..f108e93 100644 --- a/src/analysis/scan/context.c +++ b/src/analysis/scan/context.c @@ -763,7 +763,9 @@ bool g_scan_context_has_match_for_rule(GScanContext *context, const char *name) bool result; /* Bilan à retourner */ size_t i; /* Boucle de parcours */ rule_condition_t *cond; /* Condition à considérer */ + GScanScope *scope; /* Définition de portées */ GScanExpression *new; /* Nouvelle expression réduite */ + ScanReductionState state; /* Statut d'une réduction */ bool valid; /* Validité d'une récupération */ result = false; @@ -786,20 +788,26 @@ bool g_scan_context_has_match_for_rule(GScanContext *context, const char *name) if (!cond->final_reduced) { - valid = g_scan_expression_reduce(cond->expr, context, NULL, &new); - if (!valid || new == NULL) goto exit; + scope = g_scan_scope_new(name); + + state = g_scan_expression_reduce(cond->expr, context, scope, &new); + if (state == SRS_UNRESOLVABLE) goto exit_reduction; g_object_unref(G_OBJECT(cond->expr)); cond->expr = new; - valid = g_scan_expression_reduce_to_boolean(cond->expr, context, NULL, &new); - if (!valid || new == NULL) goto exit; + valid = g_scan_expression_reduce_to_boolean(cond->expr, context, scope, &new); + if (!valid || new == NULL) goto exit_reduction; g_object_unref(G_OBJECT(cond->expr)); cond->expr = new; cond->final_reduced = true; + exit_reduction: + + g_object_unref(G_OBJECT(scope)); + } /* Tentative de récupération d'un bilan final */ |