mdsteele / rust-cfb

Rust library for reading/writing Compound File Binary (structured storage) files
MIT License
46 stars 20 forks source link

Fix panic and infinite loop cases #24

Closed MJVL closed 2 years ago

MJVL commented 2 years ago

This PR fixes multiple panics as well as an infinite loop. The three panics can be found within:

This also fixes a memory exhaustion infinite loop (loop_in_chain), and simplifies some loop checking logic for the mirrored code in minichain, leading to a small perf increase.

As far as I can tell this encapsulates all low hanging fruit from #18 and my own testing, as I'm unable to find any further panics or timeouts after about an hour of fuzzing with millions of execs.

While it's probably best to refactor most debug_asserts into guarded error cases, replacing these few seems to have done the trick for now, as these safeguard more complicated logic later on.

Regression tests were added, with files too large to nicely make in a vector added to a new tests directory.