Skip to content

Commit 6cdfc97

Browse files
committed
reflection: bounds-check the union type-vector field in VerifyVector
VerifyVector reads the union type-vector slot at vec_field.offset() - sizeof(voffset_t) via GetPointer with no VerifyField, while the value-vector slot is verified. flatbuffers::Verify can therefore dereference an out-of-range vtable offset on a malformed buffer. Add the same VerifyField the value path uses before reading the type vector.
1 parent 38df293 commit 6cdfc97

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/reflection.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ static bool VerifyVector(flatbuffers::Verifier& v,
153153
table, vec_field);
154154
if (!v.VerifyVector(vec)) return false;
155155
if (!vec) return true;
156+
if (!table.VerifyField<uoffset_t>(
157+
v, vec_field.offset() - sizeof(voffset_t), sizeof(uoffset_t)))
158+
return false;
156159
auto type_vec = table.GetPointer<Vector<uint8_t>*>(vec_field.offset() -
157160
sizeof(voffset_t));
158161
if (!v.VerifyVector(type_vec)) return false;

0 commit comments

Comments
 (0)