ultimate-research / ssbh_lib

Reading and writing SSBH file formats in Rust
MIT License
8 stars 3 forks source link

fuzz testing fails for adj and meshex due to length fields #117

Open ScanMountGoat opened 2 years ago

ScanMountGoat commented 2 years ago

Adj and meshex both expose array lengths as fields. The following example fails to read in a write+read+write operation because of the invalid count. The same issue applies to meshex.

Adj {
    entry_count: 4244438268,
    entries: [],
    index_buffer: [
        -772,
        -772,
        -772,
        -772,
        -772,
        -772,
        -772,
    ],
}
ScanMountGoat commented 2 years ago

One solution is to avoid storing the length fields using BinRead's support for temporary variables. SsbhWrite may require an additional attribute to correctly generate the needed field. An easier option that doesn't rely on macro application order is to simply implement SsbhWrite manually to generate the necessary missing fields.

ScanMountGoat commented 2 years ago

MeshEx tests still fail since the entries and flags can be initialized with a different number of elements. The current implementation returns an error. This could be ignored in the fuzz tests to allow for checking other errors.