From 204017af9fd45e47f6a6aea3a66652581394a549 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 2 Apr 2025 11:19:33 +0800 Subject: [PATCH 1/4] test(log): fixed buffer overflow in log host test fixture --- components/log/host_test/log_test/main/log_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/log/host_test/log_test/main/log_test.cpp b/components/log/host_test/log_test/main/log_test.cpp index 4582ffb21b..8db973ca79 100644 --- a/components/log/host_test/log_test/main/log_test.cpp +++ b/components/log/host_test/log_test/main/log_test.cpp @@ -95,7 +95,7 @@ private: int print_to_buffer(const char *format, va_list args) { // Added support for multi-line log, for example ESP_LOG_BUFFER... - int ret = vsnprintf(&print_buffer[buffer_idx], BUFFER_SIZE, format, args); + int ret = vsnprintf(&print_buffer[buffer_idx], BUFFER_SIZE - buffer_idx, format, args); buffer_idx += ret; return ret; } From b1d14942904824b7dbb6856c0e176728c0e768c1 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 2 Apr 2025 11:20:15 +0800 Subject: [PATCH 2/4] ci(linux): re-enable failures for test_pytest_linux jobs --- .gitlab/ci/host-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index 102d0ef0b2..306177b32c 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -307,7 +307,6 @@ test_pytest_qemu: --qemu-extra-args \"-global driver=timer.$IDF_TARGET.timg,property=wdt_disable,value=true\" test_pytest_linux: - allow_failure: true # IDFCI-2784 [v5.5, v5.4] test_pytest_linux fails on ubuntu 24.04 extends: - .host_test_template - .before_script:build From cb29838788ed3065587bc10724533f02a4247219 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 2 Apr 2025 11:40:34 +0800 Subject: [PATCH 3/4] test(heap): fixed align_alloc issues in host test --- .../host_test_linux/main/test_heap_linux.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/heap/test_apps/host_test_linux/main/test_heap_linux.c b/components/heap/test_apps/host_test_linux/main/test_heap_linux.c index 8256993258..a00e7c5fd2 100644 --- a/components/heap/test_apps/host_test_linux/main/test_heap_linux.c +++ b/components/heap/test_apps/host_test_linux/main/test_heap_linux.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -50,7 +50,7 @@ TEST_CASE("Alloc APIs", "[heap]") TEST_CASE("Size APIs", "[heap]") { - /* These functions doesnt provide any useful information on linux + /* These functions doesn't provide any useful information on linux These "tests" are simply included to check that all the functions in the header are actually mocked */ @@ -71,21 +71,22 @@ TEST_CASE("Size APIs", "[heap]") TEST_ASSERT_TRUE(heap_caps_get_allocated_size(&info) == 0); } -#define TEST_ALIGNMENT 0x1F +#define TEST_ALIGNMENT 0x20 TEST_CASE("Aligned alloc APIs", "[heap]") { - uint8_t * p = heap_caps_aligned_alloc(TEST_ALIGNMENT, MALLOC_LEN, MALLOC_CAP_DEFAULT); + const int aligned_len = MALLOC_LEN - (MALLOC_LEN % TEST_ALIGNMENT); + uint8_t * p = heap_caps_aligned_alloc(TEST_ALIGNMENT, aligned_len, MALLOC_CAP_DEFAULT); TEST_ASSERT_NOT_NULL(p); TEST_ASSERT_TRUE(((intptr_t)p & (0x1F -1)) == 0); - memset(p, TEST_VAL, MALLOC_LEN); - TEST_ASSERT_EACH_EQUAL_HEX8(TEST_VAL, p, MALLOC_LEN); + memset(p, TEST_VAL, aligned_len); + TEST_ASSERT_EACH_EQUAL_HEX8(TEST_VAL, p, aligned_len); heap_caps_free(p); - p = heap_caps_aligned_calloc(TEST_ALIGNMENT, MALLOC_LEN, sizeof(uint8_t), MALLOC_CAP_DEFAULT); + p = heap_caps_aligned_calloc(TEST_ALIGNMENT, aligned_len, sizeof(uint8_t), MALLOC_CAP_DEFAULT); TEST_ASSERT_NOT_NULL(p); TEST_ASSERT_TRUE(((intptr_t)p & (0x1F -1)) == 0); - TEST_ASSERT_EACH_EQUAL_HEX8(0, p, MALLOC_LEN); + TEST_ASSERT_EACH_EQUAL_HEX8(0, p, aligned_len); heap_caps_free(p); } From ad821b3367db95b161483949997e1ba778612f77 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 2 Apr 2025 16:00:01 +0800 Subject: [PATCH 4/4] test(app_format): fixed buffer overflow in esp_app_format test --- components/esp_app_format/test_apps/main/test_app_desc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_app_format/test_apps/main/test_app_desc.c b/components/esp_app_format/test_apps/main/test_app_desc.c index 22b63f7b14..588ebf52ba 100644 --- a/components/esp_app_format/test_apps/main/test_app_desc.c +++ b/components/esp_app_format/test_apps/main/test_app_desc.c @@ -29,7 +29,7 @@ TEST(esp_app_format, esp_app_get_elf_sha256_test) int res; size_t len; - char ref_sha256[sha256_hex_len + 1]; + char ref_sha256[sha256_hex_len + 2]; const esp_app_desc_t* desc = esp_app_get_description(); for (int i = 0; i < sizeof(ref_sha256) / 2; ++i) { snprintf(ref_sha256 + 2 * i, 3, "%02x", desc->app_elf_sha256[i]);