]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: fix condition for community id with same ip
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 18 Jul 2025 14:11:59 +0000 (16:11 +0200)
committerJason Ish <jason.ish@oisf.net>
Fri, 1 Aug 2025 16:54:14 +0000 (10:54 -0600)
Ticket: 5689

src/output-json.c

index d902f8bd17b2d4dee8067208fa0dc7602afd3407..1e04e13c49dd1e9e67784f57dc112bc546fdac21 100644 (file)
@@ -625,7 +625,7 @@ static bool CalculateCommunityFlowIdv4(const Flow *f,
     dp = htons(dp);
 
     ipv4.seed = htons(seed);
-    if (ntohl(src) < ntohl(dst) || (src == dst && sp < dp)) {
+    if (ntohl(src) < ntohl(dst) || (src == dst && ntohs(sp) < ntohs(dp))) {
         ipv4.src = src;
         ipv4.dst = dst;
         ipv4.sp = sp;
@@ -674,7 +674,7 @@ static bool CalculateCommunityFlowIdv6(const Flow *f,
 
     ipv6.seed = htons(seed);
     int cmp_r = memcmp(&f->src, &f->dst, sizeof(f->src));
-    if ((cmp_r < 0) || (cmp_r == 0 && sp < dp)) {
+    if ((cmp_r < 0) || (cmp_r == 0 && ntohs(sp) < ntohs(dp))) {
         memcpy(&ipv6.src, &f->src.addr_data32, 16);
         memcpy(&ipv6.dst, &f->dst.addr_data32, 16);
         ipv6.sp = sp;