net: 6lowpan: Check packet size before accepting fragment

If the fragment is corrupted and tells that the total packet
size is too big, then we must discard the packet.

Change-Id: I6257d677d1d2cfc30f37ad6fe4d59051d0e041ef
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-03-21 14:17:52 +02:00 committed by Gerrit Code Review
commit 746f81be1b

View file

@ -627,6 +627,12 @@ static int reassemble(struct net_buf *mbuf)
PRINTF("size %d, tag %d, offset %d\n", frag_size, frag_tag, frag_offset);
if (frag_size > IP_BUF_MAX_DATA) {
PRINTF("Too big packet %d bytes (max %d), fragment discarded\n",
frag_size, IP_BUF_MAX_DATA);
goto fail;
}
uip_packetbuf_hdr_len(mbuf) += SICSLOWPAN_FRAG1_HDR_LEN;
first_fragment = 1;
is_fragment = 1;