ultimate-research / ssbh_lib

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

fix failed fuzz tests for ssbh_data conversions #122

Closed ScanMountGoat closed 2 years ago

ScanMountGoat commented 2 years ago

ssbh_data doesn't provide the same guarantee as ssbh_lib that binary data will be preserved. All we can really test for is that the conversion will be free of panics or memory errors for arbitrary inputs. A major source of potential errors is encoding/decoding byte buffers for mesh and skel.

ScanMountGoat commented 2 years ago

It may make more sense to move the null pointer checks for MeshEx to the parser itself. This would require a new non nullable type. A simpler option is to switch from From to TryFrom and return an error on null pointers for non strings.

ScanMountGoat commented 2 years ago

The current implementation for anim decoding can potentially allocate too much memory when the bit count is zero. This insert the default valueframe_count many times. A bit count of zero and a non zero frame count is a legal way to represent a series of default values, so this may be too difficult to check for.

ScanMountGoat commented 2 years ago

One possible solution is to detect the case with identical compressed values in the track and convert to a single value for ssbh_data. This results in an uncompressed track when saving. It's unclear if potentially changing the interpolation behavior would matter in this case. This approach will require some extra care when handling NaN values.