mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-09 21:20:17 +00:00
perform boundary check before searching to prevent security vulnerabilities
This commit is contained in:
parent
cb15db1f0e
commit
4b10090f70
@ -266,6 +266,7 @@ int utf8len(unsigned char c, bool suppress){
|
||||
}
|
||||
|
||||
int Str::index(const Str& sub, int start) const {
|
||||
if (start < 0 || start >= this->u8_length()) return -1;
|
||||
auto p = std::search(data + start, data + size, sub.data, sub.data + sub.size);
|
||||
if(p == data + size) return -1;
|
||||
return p - data;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user