Skip to content
Permalink
Browse files

net/udp: Check UDP header's length attribute

Length should be at least of UDP header size but not bigger than actual
payload size.

Reported-by: Ruslan Mstoi <ruslan.mstoi@intel.com>

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
  • Loading branch information...
tbursztyka authored and jukkar committed May 29, 2019
1 parent a46db55 commit a5b90a4aad09baac40b10d52b0883bb8bf4bb4be
Showing with 7 additions and 0 deletions.
  1. +7 −0 subsys/net/ip/udp.c
@@ -154,6 +154,13 @@ struct net_udp_hdr *net_udp_input(struct net_pkt *pkt,
goto drop;
}

if (ntohs(udp_hdr->len) != (net_pkt_get_len(pkt) -
net_pkt_ip_hdr_len(pkt) -
net_pkt_ipv6_ext_len(pkt))) {
NET_DBG("DROP: Invalid hdr length");
goto drop;
}

if (IS_ENABLED(CONFIG_NET_UDP_CHECKSUM) &&
net_if_need_calc_rx_checksum(net_pkt_iface(pkt))) {
if (IS_ENABLED(CONFIG_NET_UDP_MISSING_CHECKSUM) &&

0 comments on commit a5b90a4

Please sign in to comment.
You can’t perform that action at this time.