]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
datasets: fix set with ip sets 13270/head 13280/head
authorEric Leblond <el@stamus-networks.com>
Tue, 6 May 2025 16:17:08 +0000 (18:17 +0200)
committerPhilippe Antoine <pantoine@oisf.net>
Tue, 20 May 2025 12:50:20 +0000 (14:50 +0200)
It can get an IPv6 or an IPv4 so we need to handle both length.

Ticket: #7689
(cherry picked from commit e499a98ba995ac25b40c5957faeff11c88410e93)

src/datasets.c

index db9da766802c99299c9c45e467d7a55131bc1594..e82bed27ad3f6f4c80e75acc369caa28b84c1938 100644 (file)
@@ -1502,12 +1502,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);