Skip to content

Commit

Permalink
net: 6lo: Drop pkt if it is too short
Browse files Browse the repository at this point in the history
If the pkt is corrupted and the offset would be larger than
the actual packet length, then print information about that and
drop the packet.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar committed Oct 19, 2017
1 parent ee107ba commit 4463035
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions subsys/net/ip/6lo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,12 @@ static inline bool uncompress_IPHC_header(struct net_pkt *pkt)
net_buf_add(frag, NET_UDPH_LEN);

end:
if (pkt->frags->len < offset) {
NET_ERR("pkt %p too short len %d vs %d", pkt,
pkt->frags->len, offset);
goto fail;
}

/* Move the data to beginning, no need for headers now */
NET_DBG("Removing %u bytes of compressed hdr", offset);
memmove(pkt->frags->data, pkt->frags->data + offset,
Expand Down

0 comments on commit 4463035

Please sign in to comment.