diff --git a/src/decode-udp.c b/src/decode-udp.c index 13c665cdd8..1ecaf54f6f 100644 --- a/src/decode-udp.c +++ b/src/decode-udp.c @@ -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;