decode/udp: fix payload_len calculation

Fix payload_len calculation post removal of the condition that returned
error code if the length to the decode fn did not match the length of
header from the UDP packet.

Bug 5379
pull/8459/head
Shivani Bhardwaj 3 years ago committed by Victor Julien
parent eebdfe9a3e
commit f941ceae2b

@ -56,11 +56,16 @@ static int DecodeUDPPacket(ThreadVars *t, Packet *p, const uint8_t *pkt, uint16_
return -1;
}
if (unlikely(UDP_GET_LEN(p) < UDP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, UDP_LEN_INVALID);
return -1;
}
SET_UDP_SRC_PORT(p,&p->sp);
SET_UDP_DST_PORT(p,&p->dp);
p->payload = (uint8_t *)pkt + UDP_HEADER_LEN;
p->payload_len = len - UDP_HEADER_LEN;
p->payload_len = UDP_GET_LEN(p) - UDP_HEADER_LEN;
p->proto = IPPROTO_UDP;

Loading…
Cancel
Save