mirror of
https://github.com/WeActStudio/ArduinoCore-AT32F4.git
synced 2026-05-21 09:22:01 +00:00
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:
@@ -735,7 +735,7 @@ void String::remove(unsigned int index, unsigned int count)
|
|||||||
}
|
}
|
||||||
char *writeTo = buffer + index;
|
char *writeTo = buffer + index;
|
||||||
len = len - count;
|
len = len - count;
|
||||||
strncpy(writeTo, buffer + index + count, len - index);
|
memmove(writeTo, buffer + index + count, len - index);
|
||||||
buffer[len] = 0;
|
buffer[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user