String: Fix remove method

strncpy() can not use overlapped memory regions and generates corrupted data
with certain inputs. Changed to memmove. Verified with fuzzing against
std::string::erase.
This commit is contained in:
Chris
2022-09-18 04:03:22 -04:00
parent c2ac620686
commit ecd958e50e

View File

@@ -735,7 +735,7 @@ void String::remove(unsigned int index, unsigned int count)
}
char *writeTo = buffer + index;
len = len - count;
strncpy(writeTo, buffer + index + count, len - index);
memmove(writeTo, buffer + index + count, len - index);
buffer[len] = 0;
}