Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cores/esp8266/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool String::concat(const char *cstr, unsigned int length) {
return true;
if (!reserve(newlen))
return false;
memmove_P(wbuffer() + len(), cstr, length + 1);
memmove_P(wbuffer() + len(), cstr, length);
setLen(newlen);
wbuffer()[newlen] = 0;
return true;
Expand Down
9 changes: 9 additions & 0 deletions tests/host/core/test_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,12 @@ TEST_CASE("String chaining", "[core][String]")
REQUIRE(static_cast<const void*>(result.c_str()) == static_cast<const void*>(ptr));
}
}

TEST_CASE("String concat OOB #8198", "[core][String]")
{
char *p = (char*)malloc(16);
memset(p, 'x', 16);
String s = "abcd";
s.concat(p, 16);
REQUIRE(!strcmp(s.c_str(), "abcdxxxxxxxxxxxxxxxx"));
}