Skip to content

Commit 2193e75

Browse files
Lukas Sismislukashino
Lukas Sismis
authored andcommitted
decode-udp: Add exception for invalid length on padded packets
If the original packet is shorter than Ethernet's minimal transmission unit (64B), the transmitting device pads the packet to the given size. Padding is added to the IP layer but the UDP layer remains unaffected. As a result, the UDP header length does not reach the end of the packet as there is still padding after the UDP layer. Redmine ticket: OISF#5693
1 parent a4239d4 commit 2193e75

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/decode-ethernet.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define __DECODE_ETHERNET_H__
2626

2727
#define ETHERNET_HEADER_LEN 14
28+
#define ETHERNET_PKT_MIN_LEN 60 // Min. transmission unit on Ethernet is 64B (4B for FCS)
2829

2930
/* Cisco Fabric Path / DCE header length. */
3031
#define ETHERNET_DCE_HEADER_LEN (ETHERNET_HEADER_LEN + 2)

src/decode-udp.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ static int DecodeUDPPacket(ThreadVars *t, Packet *p, const uint8_t *pkt, uint16_
5656
return -1;
5757
}
5858

59-
if (unlikely(len != UDP_GET_LEN(p))) {
59+
if (unlikely(len != UDP_GET_LEN(p) &&
60+
// avoid flagging IP padded packets to the minimal Ethernet unit as invalid HLEN
61+
(p->ethh != NULL && p->pktlen > ETHERNET_PKT_MIN_LEN))) {
6062
ENGINE_SET_INVALID_EVENT(p, UDP_HLEN_INVALID);
6163
return -1;
6264
}

0 commit comments

Comments
 (0)