We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9f0ec1 commit 53df799Copy full SHA for 53df799
src/system.c
@@ -382,6 +382,10 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
382
struct complete_packet *tx_pkt = (struct complete_packet *)p_tx_buf_transfer;
383
struct complete_packet *rx_pkt = (struct complete_packet *)RX_Buffer;
384
385
+ /* Limit the amount of data copied to prevent buffer overflow. */
386
+ if (rx_pkt->header.size > sizeof(rx_pkt_userspace))
387
+ rx_pkt->header.size = sizeof(rx_pkt_userspace);
388
+
389
/* The SPI transfer is now complete, copy to userspace memory. */
390
memcpy((void *)rx_pkt_userspace, &(rx_pkt->data), rx_pkt->header.size);
391
0 commit comments