]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
datasets: fix set with ip sets
authorEric Leblond <el@stamus-networks.com>
Tue, 6 May 2025 16:17:08 +0000 (18:17 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 7 May 2025 19:00:57 +0000 (21:00 +0200)
It can get an IPv6 or an IPv4 so we need to handle both length.

Ticket: #7689

src/datasets.c

index 8a734d41fbcbdb3fdd2c41ad2b8fda0ce19757ae..93712914e630d7d42d096a237324c86e0a7537fe 100644 (file)
@@ -1191,12 +1191,12 @@ static int DatasetAddIPv6(Dataset *set, const uint8_t *data, const uint32_t data
         return -1;
     }
 
-    if (data_len != 16) {
+    if (data_len != 16 && data_len != 4) {
         return -2;
     }
 
     IPv6Type lookup = { .rep.value = 0 };
-    memcpy(lookup.ipv6, data, 16);
+    memcpy(lookup.ipv6, data, data_len);
     struct THashDataGetResult res = THashGetFromHash(set->hash, &lookup);
     if (res.data) {
         DatasetUnlockData(res.data);