Skip to content

Commit b6f51c7

Browse files
keith-packardmbolivar-nordic
authored andcommitted
tests/spi_loopback: Fix buffer sizes to avoid buffer overflow
The initialized test buffers tx_data and tx2_data were not given a specific size, but were initialized with one more byte than the uninitialized buffers they get copied to. As a result, the memcpy found a buffer overflow. Fix this by setting the source buffer sizes to match the destination. Signed-off-by: Keith Packard <[email protected]>
1 parent b7313f8 commit b6f51c7

File tree

1 file changed

+2
-2
lines changed
  • tests/drivers/spi/spi_loopback/src

1 file changed

+2
-2
lines changed

tests/drivers/spi/spi_loopback/src/spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ struct spi_cs_control spi_cs = {
4343
#define BUF2_SIZE 36
4444

4545
#if CONFIG_NOCACHE_MEMORY
46-
static const char tx_data[] = "0123456789abcdef\0";
46+
static const char tx_data[BUF_SIZE] = "0123456789abcdef\0";
4747
static __aligned(32) char buffer_tx[BUF_SIZE] __used __attribute__((__section__(".nocache")));
4848
static __aligned(32) char buffer_rx[BUF_SIZE] __used __attribute__((__section__(".nocache")));
49-
static const char tx2_data[] = "Thequickbrownfoxjumpsoverthelazydog\0";
49+
static const char tx2_data[BUF2_SIZE] = "Thequickbrownfoxjumpsoverthelazydog\0";
5050
static __aligned(32) char buffer2_tx[BUF2_SIZE] __used __attribute__((__section__(".nocache")));
5151
static __aligned(32) char buffer2_rx[BUF2_SIZE] __used __attribute__((__section__(".nocache")));
5252
#else

0 commit comments

Comments
 (0)