From 8900975e122104d13f2e70667ef9f4ace81ef78b Mon Sep 17 00:00:00 2001 From: Andreas Herz Date: Fri, 12 Jan 2024 15:38:28 +0100 Subject: [PATCH] dataset: cleanup datasets that hit the memcap while loading Datasets that hit the memcap limit need to be discarded if the memcap is hit or otherwise the datasets are still loaded with partial data while the signature is not loaded due to the memcap error. Ticket: #6678 --- src/datasets.c | 5 +++++ src/detect-dataset.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/datasets.c b/src/datasets.c index d89ed8df59da..01ef5bb47c90 100644 --- a/src/datasets.c +++ b/src/datasets.c @@ -746,6 +746,11 @@ Dataset *DatasetGet(const char *name, enum DatasetTypes type, const char *save, break; } + if (set->hash && SC_ATOMIC_GET(set->hash->memcap_reached)) { + SCLogError("dataset too large for set memcap"); + goto out_err; + } + SCLogDebug("set %p/%s type %u save %s load %s", set, set->name, set->type, set->save, set->load); diff --git a/src/detect-dataset.c b/src/detect-dataset.c index f6d0d844e2e5..70e9e67c946d 100644 --- a/src/detect-dataset.c +++ b/src/detect-dataset.c @@ -406,10 +406,6 @@ int DetectDatasetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawst SCLogError("failed to set up dataset '%s'.", name); return -1; } - if (set->hash && SC_ATOMIC_GET(set->hash->memcap_reached)) { - SCLogError("dataset too large for set memcap"); - return -1; - } cd = SCCalloc(1, sizeof(DetectDatasetData)); if (unlikely(cd == NULL))