Skip to content

Commit c6de882

Browse files
committed
Properly fix possible buffer overflow
Fix for #60
1 parent 53df799 commit c6de882

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/system.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
383383
struct complete_packet *rx_pkt = (struct complete_packet *)RX_Buffer;
384384

385385
/* 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);
386+
if (rx_pkt->header.size > SPI_DMA_BUFFER_SIZE)
387+
rx_pkt->header.size = SPI_DMA_BUFFER_SIZE;
388388

389389
/* The SPI transfer is now complete, copy to userspace memory. */
390390
memcpy((void *)rx_pkt_userspace, &(rx_pkt->data), rx_pkt->header.size);

0 commit comments

Comments
 (0)