mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-01 17:57:25 +00:00
Fix logic inversion in FlexBuffers VerifyKey() (#9072)
VerifyKey() returns true on the first non-zero byte instead of checking for a null terminator. This causes VerifyBuffer() to accept FlexBuffers with non-null-terminated keys. Subsequent access to those keys via strlen()/strcmp() reads out of bounds. The condition if (*p++) should be if (!*p++) — return true when a null terminator is found, not when any non-zero byte is found. Confirmed with AddressSanitizer: heap-buffer-overflow in strlen() after VerifyBuffer() returns true on a corrupted buffer.
This commit is contained in:
parent
bab10754d9
commit
a6979fe14a
1 changed files with 1 additions and 1 deletions
|
|
@ -1976,7 +1976,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
|||
bool VerifyKey(const uint8_t* p) {
|
||||
FLEX_CHECK_VERIFIED(p, PackedType(BIT_WIDTH_8, FBT_KEY));
|
||||
while (p < buf_ + size_)
|
||||
if (*p++) return true;
|
||||
if (!*p++) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue