Skip to content

Commit 8e62e70

Browse files
rlubosjgl-meta
authored andcommitted
drivers: ieee802154_nrf5: Add payload length check on TX
In case upper layer does not follow the convention, and the net_pkt provided to the nRF 15.4 driver had a payload larger than the maximum payload size of an individual 15.4 frame, the driver would end up with buffer overflow. Fix this by adding an extra payload_len check before attempting to copy the payload to the internal buffer. Signed-off-by: Robert Lubos <[email protected]> (cherry picked from commit cf58d11)
1 parent 1c9b37a commit 8e62e70

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,11 @@ static int nrf5_tx(const struct device *dev,
577577
uint8_t *payload = frag->data;
578578
bool ret = true;
579579

580+
if (payload_len > NRF5_PSDU_LENGTH) {
581+
LOG_ERR("Payload too large: %d", payload_len);
582+
return -EMSGSIZE;
583+
}
584+
580585
LOG_DBG("%p (%u)", payload, payload_len);
581586

582587
nrf5_radio->tx_psdu[0] = payload_len + NRF5_FCS_LENGTH;

0 commit comments

Comments
 (0)