Commit Graph

8 Commits

Author SHA1 Message Date
Sebastian Rasmussen b96dd54183
[ghostscript] Make sure that all state kept in memory. (#3619)
The default setting allows for state to be temporarily saved to disk.
This is likely to interfere with the fuzzer's knowledge about state of data.
2020-04-11 06:13:26 -07:00
Sebastian Rasmussen e2e155fe0e
Update flags and enable new sanitizer (#3587)
* [ghostscript] Replace deprecated flag by current flag.

In old versions of Ghostscript the flag -dPARANOIDSAFER did
more checks than -dSAFER did. In modern versions the two flags
are identical. Moreover the flag -dPARANOIDSAFER has been
deprecated for a long time, and may be removed in the future.

In Ghostscript 9.50 and later -dSAFER is the default, and does
not have to be specified. To be able to test older yet still
modern Ghostscript versions without problems -dSAFER is used.

* [ghostscript] Force enable banding while rendering.

Ghostscript uses the set resolution to determine if banding should be
enabled during rendering, or not. Under normal circumstances documents
are rendered at maybe 600 DPI, but to conserve memory while running in
OSS-fuzz 200 DPI is used (-r200x200). To still test the banding code
used under normal circumstances banding is force enabled.

Moreover BufferSpace is used to determine the band height and thus the
number of bands. At 600 DPI this is normally 4Mbyte, so a reasonable
approximate at 200 DPI is 450k. Thus BufferSpace is also set.

* [ghostscript] Enable another sanitizer to see more issues.
2020-04-07 09:10:11 -07:00
Sebastian Rasmussen cd848bbd39
[ghostscript] Avoid printing raster output to stdout. (#3547)
Previously raster output data was printed on stdout. While this
is similar to how Ghostscript is run by CUPS's gstoraster filter it
unnecessarily prolongs execution time for many files.

Changing the output file still means that CUPS will be sent the
rasterized page and will be asked to convert it to a PWG raster which
it then dutifully writes to /dev/null. Thus no major difference is
expected in what code is executed in Ghostscript (or CUPS).

When run locally on a testcase found among the problematic files here:
gs://ghostscript-corpus.clusterfuzz-external.appspot.com/libFuzzer/
fuzzer target reported a timeout after 120 seconds before this commit.
After this commit the fuzzer target succeeded after about 3 seconds.
2020-03-27 13:32:10 -07:00
Sebastian Rasmussen 65390a9774
[ghostscript] Relicense target fuzzer under Apache 2.0 license. (#3440)
When contributed to OSS-fuzz the Ghostscript target fuzzer was
licensed under a "BSD-style" license, referring to a LICENSE file
that actually contained an Apache 2.0 license! Recently the OSS-fuzz
project has added a presubmit check that validates the license of
each project's target fuzzer, causing the Ghostscript target fuzzer
to now fail the test. The Ghostscript target fuzzer therefore needs
to be relicensed under Apache 2.0.

This commit relicenses the existing target fuzzer code under
Apache 2.0 so that the Ghostscript target fuzzer code will pass
OSS-fuzz's presubmit checks allowing for further development.
2020-02-28 12:32:13 -08:00
Sebastian Rasmussen 879e06798f
[ghostscript] Add place holder program name. (#3438)
The first element in the argument array to gsapi_new_instance()
is ignored since it normally is the program name. This means that
the commit introducing the "-K" argument to limit memory usage did
not have its intended effect since the "-K" argument was ignored.
Moreover, prior to that the resolution argument "-r200x200" was
being unintentionally ignored. By introducing a place holder program
name all arguments are taken into account and the reader is reminded
that the first argument is the program name.
2020-02-27 12:29:14 -08:00
Sebastian Rasmussen 198345dc17 [ghostscript] Limit ghostscript memory usage to 1Gbyte. (#2890) 2019-09-26 08:35:13 -07:00
Benjamin Gordon 8934ff6f8b Two fixes for ghostcript (#2562)
* [ghostscript] Fix ininitialized pointer

Passing an invalid pointer causes a crash in gs_new_instance.

* [ghostscript] Add seed corpus

Use the examples distributed with ghostcript as a seed corpus.
2019-07-02 07:38:50 -07:00
Benjamin Gordon 9b715c91c2 [ghostscript] New project: ghostscript (#2544) 2019-06-27 09:59:20 -07:00