Skip to content

Commit d08c6ee

Browse files
mniestrojcfriedt
authored andcommitted
drivers: net: ppp: fix removing CRC16 from packet
CRC16 was removed by simply decreasing length of the last fragment by 2. This worked as long as last fragment was longer than 1 byte. If not, then last fragment was corrupted (its length ended up being 65535), leading to undefined behavior. Fix CRC16 removal by utilizing recently introduced net_pkt_remove_tail(), that properly handles multiple fragments. Reported-by: Jim Paris <[email protected]> Signed-off-by: Marcin Niestroj <[email protected]>
1 parent 1ce1d19 commit d08c6ee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ppp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ static void ppp_process_msg(struct ppp_driver_context *ppp)
416416
#endif
417417
net_pkt_unref(ppp->pkt);
418418
} else {
419-
/* Skip FCS bytes (2) */
420-
net_buf_frag_last(ppp->pkt->buffer)->len -= 2;
419+
/* Remove FCS bytes (2) */
420+
net_pkt_remove_tail(ppp->pkt, 2);
421421

422422
/* Make sure we now start reading from PPP header in
423423
* PPP L2 recv()

0 commit comments

Comments
 (0)