Skip to content

Commit

Permalink
Prevent buffer overflow in Value::getStringBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold authored and snej committed Jul 19, 2023
1 parent ccae083 commit 28baa5b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Fleece/Core/Value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ namespace fleece { namespace impl {
// This means the actual length follows as a varint:
uint32_t length;
size_t lengthBytes = GetUVarInt32(s, &length);
if (_usuallyFalse(lengthBytes == 0))
// Invalid data, but I'm not allowed to throw an exception.
return nullslice;
return slice(&s[lengthBytes], length);
}
return s;
Expand Down

0 comments on commit 28baa5b

Please sign in to comment.