google / zopfli

Zopfli Compression Algorithm is a compression library programmed in C to perform very good, but slow, deflate or zlib compression.
Apache License 2.0
3.43k stars 330 forks source link

Integrating with OSS-Fuzz #160

Closed Google-Autofuzz closed 5 years ago

Google-Autofuzz commented 5 years ago

Greetings zopfli developers and contributors,

We’re reaching out because your project is an important part of the open source ecosystem, and we’d like to invite you to integrate with our fuzzing service, OSS-Fuzz. OSS-Fuzz is a free fuzzing infrastructure you can use to identify security vulnerabilities and stability bugs in your project. OSS-Fuzz will:

Many widely used open source projects like OpenSSL, FFmpeg, LibreOffice, and ImageMagick are fuzzing via OSS-Fuzz, which helps them find and remediate critical issues.

Even though typical integrations can be done in < 100 LoC, we have a reward program in place which aims to recognize folks who are not just contributing to open source, but are also working hard to make it more secure.

We want to stress that anyone who meets the eligibility criteria and integrates a project with OSS-Fuzz is eligible for a reward.

To help you getting started, we can provide you our internal fuzzer for your project that you are welcome to use directly, or to use it as a starting point.

If you're not interested in integrating with OSS-Fuzz, it would be helpful for us to understand why—lack of interest, lack of time, or something else—so we can better support projects like yours in the future.

If we’ve missed your question in our FAQ, feel free to reply or reach out to us at oss-fuzz-outreach@googlegroups.com.

Thanks!

Tommy OSS-Fuzz Team

Google-Autofuzz commented 5 years ago

This is the fuzz target, zopfli_comopress_fuzzer.cc, as shown below. It uses a header library called FuzzedDataProvider. Please take a look and we are happy that you do consider to use OSS-Fuzz.

#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <string>

#include "FuzzedDataProvider.h"
#include "zopfli.h"

// This target should be written in C, since the underlying library is C, but we
// make use of FuzzedDataProvider.

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  FuzzedDataProvider stream(data, size);

  ZopfliOptions options;
  ZopfliInitOptions(&options);

  const ZopfliFormat format = stream.PickValueInArray(
      {ZOPFLI_FORMAT_GZIP, ZOPFLI_FORMAT_ZLIB, ZOPFLI_FORMAT_DEFLATE});

  unsigned char* outbuf = nullptr;
  size_t outsize = 0;
  std::string input = stream.ConsumeRemainingBytesAsString();

  ZopfliCompress(&options, format,
                 reinterpret_cast<const unsigned char*>(input.data()),
                 input.size(), &outbuf, &outsize);

  if (outbuf != nullptr) {
    free(outbuf);
  }

  return 0;
}
lvandeve commented 5 years ago

Thank you for doing this in https://github.com/google/oss-fuzz/pull/2631