From 4db89597b09f6e72191ebaedb2ab110181982aa9 Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Mon, 31 Jul 2023 20:49:18 +0200 Subject: [PATCH 1/2] test: fix buffer overflow in String::getBytes test --- test/src/String/test_characterAccessFunc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/src/String/test_characterAccessFunc.cpp b/test/src/String/test_characterAccessFunc.cpp index 329cca43..d0f02383 100644 --- a/test/src/String/test_characterAccessFunc.cpp +++ b/test/src/String/test_characterAccessFunc.cpp @@ -45,10 +45,11 @@ TEST_CASE ("Testing String::getBytes(unsigned char, unsigned int, unsigned int)" WHEN("Valid operation") { arduino::String str("Hello"); - unsigned char buf[2]; + unsigned char buf[3]; str.getBytes(buf, 5, 3); REQUIRE(buf[0] == 'l'); REQUIRE(buf[1] == 'o'); + REQUIRE(buf[2] == '\0'); } } From 363c2c494d5d00e500e4ec6f82915230151f69ee Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Mon, 31 Jul 2023 20:51:39 +0200 Subject: [PATCH 2/2] test: fix CMAKE_{C,CXX}_FLAGS manipulation Use string concatenation instead of creating a list. --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fce6e014..2df2eacf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -121,8 +121,8 @@ add_compile_definitions(HOST) add_compile_options(-Wall -Wextra -Wpedantic -Werror) add_compile_options(-Wno-cast-function-type) -set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "--coverage") -set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--coverage -Wno-deprecated-copy") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -Wno-deprecated-copy") ##########################################################################