Skip to content

Commit af91a54

Browse files
author
Ruslan Mstoi
committed
net: icmpv4: Drop ICMPv4 packet if ICMP header is NULL
This commit fixes the crash of echo_server from malformed ICMPv4 packet. Fixes #6081 Signed-off-by: Ruslan Mstoi <[email protected]>
1 parent 2b27344 commit af91a54

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/net/ip/ipv4.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ static inline enum net_verdict process_icmpv4_pkt(struct net_pkt *pkt,
142142
struct net_icmp_hdr hdr, *icmp_hdr;
143143

144144
icmp_hdr = net_icmpv4_get_hdr(pkt, &hdr);
145+
if (!icmp_hdr) {
146+
NET_DBG("NULL ICMPv4 header - dropping");
147+
return NET_DROP;
148+
}
145149

146150
NET_DBG("ICMPv4 packet received type %d code %d",
147151
icmp_hdr->type, icmp_hdr->code);

0 commit comments

Comments
 (0)