From 2fbde4af19158e498c0c2fd1793ca44d47b15afa Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 10 Nov 2022 22:49:58 +0100 Subject: [PATCH] tests/pkg_tinyvcdiff: fix stack overflow Move some variables from stack to `.bss` / `.data` to avoid stack overflows, which are detected by the MPU stack guard (e.g. on the Nucleo-F767ZI that I used) and results in the test failing. --- tests/pkg_tinyvcdiff/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/pkg_tinyvcdiff/main.c b/tests/pkg_tinyvcdiff/main.c index c22c0447fa..2285622dc7 100644 --- a/tests/pkg_tinyvcdiff/main.c +++ b/tests/pkg_tinyvcdiff/main.c @@ -39,6 +39,13 @@ static vcdiff_t vcdiff; static fake_mtd_t storage_a = FAKE_MTD_INIT; static fake_mtd_t storage_b = FAKE_MTD_INIT; +static littlefs2_desc_t fs = { .dev = &storage_a.mtd }; +static vfs_mount_t mnt = { + .mount_point = "/mnt", + .fs = &littlefs2_file_system, + .private_data = &fs, +}; +static uint8_t target_buf[sizeof(target_bin)]; static void test_tinyvcdiff_mtd(void) { @@ -65,7 +72,6 @@ static void test_tinyvcdiff_mtd(void) TEST_ASSERT_EQUAL_INT(0, rc); /* check reconsturcted target */ - uint8_t target_buf[target_bin_len]; mtd_read(target_mtd, target_buf, 0, sizeof(target_buf)); TEST_ASSERT_EQUAL_INT(0, memcmp(target_bin, target_buf, sizeof(target_buf))); } @@ -75,12 +81,6 @@ static void test_tinyvcdiff_vfs(void) int rc; int source_fd, target_fd; - littlefs2_desc_t fs = { .dev = &storage_a.mtd }; - vfs_mount_t mnt = { - .mount_point = "/mnt", - .fs = &littlefs2_file_system, - .private_data = &fs, - }; vfs_format(&mnt); vfs_mount(&mnt); @@ -110,8 +110,8 @@ static void test_tinyvcdiff_vfs(void) vfs_close(target_fd); /* check reconsturcted target */ + memset(target_buf, 0, sizeof(target_buf)); target_fd = vfs_open("/mnt/target", O_RDONLY, 0); - uint8_t target_buf[target_bin_len]; vfs_read(target_fd, target_buf, sizeof(target_buf)); TEST_ASSERT_EQUAL_INT(0, memcmp(target_bin, target_buf, sizeof(target_buf))); vfs_close(target_fd);