Skip to content

Commit

Permalink
Merge pull request #193 from tttapa/patch-2
Browse files Browse the repository at this point in the history
Fix stack buffer overflow in String::getBytes() test
  • Loading branch information
aentinger authored Aug 1, 2023
2 parents 5b9faf6 + 363c2c4 commit 84b98c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

##########################################################################

Expand Down
3 changes: 2 additions & 1 deletion test/src/String/test_characterAccessFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down

0 comments on commit 84b98c7

Please sign in to comment.