Commit 2b7637df authored by Philipp Hasper's avatar Philipp Hasper

Fixed buffer overflow in string handling

pos should never exceed strlen, else the overflow check 'if (!len)' will wrongfully pass
parent 0726c4d4
......@@ -87,7 +87,7 @@ String::String(const std::string& str, size_t pos, size_t len)
: cstr_(0), len_(0)
{
size_t strlen = str.size();
pos = max(pos, strlen);
pos = min(pos, strlen);
len = min(strlen - pos, len);
if (!len) return;
memcpy(allocate(len), str.c_str() + pos, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment