localcc / gvas

GVAS file format parsing library for rust
MIT License
19 stars 2 forks source link

Validate that all property lengths match the size of data actually read. #31

Closed scottanderson closed 1 year ago

scottanderson commented 1 year ago

Properties that have a fixed size (ie, integer types) generally use the check_size! macro to validate that the field size matches the expected size. For most other types, however, the length field is ignored. We should strive to validate that the read length always matches the property header's length field.

ArrayProperty::read offers a good example of validating complex properties using the validate! macro, which raises errors in case of condition failure.