From: Victor Julien Date: Sun, 31 Mar 2024 19:13:40 +0000 (+0200) Subject: unittests: don't set ports for non-port proto X-Git-Tag: suricata-8.0.0-beta1~1569 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e557ba0460bb452cfa4cde51d9f970ac0c2ce665;p=thirdparty%2Fsuricata.git unittests: don't set ports for non-port proto --- diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index 743ed1f43e..2b03cdeb43 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -262,12 +262,14 @@ Packet *UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len, if (inet_pton(AF_INET, src, &in) != 1) goto error; p->src.addr_data32[0] = in.s_addr; - p->sp = sport; + if (ipproto == IPPROTO_TCP || ipproto == IPPROTO_UDP || ipproto == IPPROTO_SCTP) + p->sp = sport; if (inet_pton(AF_INET, dst, &in) != 1) goto error; p->dst.addr_data32[0] = in.s_addr; - p->dp = dport; + if (ipproto == IPPROTO_TCP || ipproto == IPPROTO_UDP || ipproto == IPPROTO_SCTP) + p->dp = dport; p->ip4h = (IPV4Hdr *)GET_PKT_DATA(p); if (p->ip4h == NULL)