1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-31 01:11:21 +01:00

udp: discard UDP packets with zero checksum.

RFC 2460 Section 8.1

> IPv6 receivers must discard UDP packets containing a zero checksum,
> and should log the error.
This commit is contained in:
Yonezawa-T2 2016-02-22 20:36:14 +09:00
parent e92c355aba
commit b1dd2818fe

View File

@ -137,6 +137,15 @@ static void _receive(gnrc_pktsnip_t *pkt)
hdr = (udp_hdr_t *)udp->data;
/* validate checksum */
if (byteorder_ntohs(hdr->checksum) == 0) {
/* RFC 2460 Section 8.1
* "IPv6 receivers must discard UDP packets containing a zero checksum,
* and should log the error."
*/
DEBUG("udp: received packet with zero checksum, dropping it\n");
gnrc_pktbuf_release(pkt);
return;
}
if (_calc_csum(udp, ipv6, pkt) != 0xFFFF) {
DEBUG("udp: received packet with invalid checksum, dropping it\n");
gnrc_pktbuf_release(pkt);