yob / pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.
MIT License
1.81k stars 271 forks source link

Resurrect Fuzzer script by bcoles #429

Closed yob closed 2 years ago

yob commented 2 years ago

In #248 @bcoles provided a fuzzer that we never merged.

Now that I'm experimenting with sorbet and static type checking, I'm curious to explore whether the type checking can help avoid many of the exceptions surfaced by the fuzzer.

In #428 the fuzzer was useful for testing that hypothesis on the CMap class, so I think it'd be helpful to have the script on main. This resurrects the original fuzzer, with a small fix to avoid a crash thanks to frozen strings.

yob commented 2 years ago

To run the fuzzer against the checked out code:

$ ruby -Ilib tools/fuzz.rb spec/data/*.pdf               
------------------------------------------------------------                                              
% Fuzzer for pdf-reader Ruby gem                                                                          
------------------------------------------------------------