mirror of https://github.com/google/oss-fuzz.git
27 lines
795 B
C++
27 lines
795 B
C++
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <fstream>
|
|
#include "dgif_fuzz_common.h"
|
|
|
|
#include "libprotobuf-mutator/src/libfuzzer/libfuzzer_macro.h"
|
|
#include "ProtoToGif.h"
|
|
|
|
using namespace gifProtoFuzzer;
|
|
|
|
DEFINE_PROTO_FUZZER(const GifProto &gif_proto)
|
|
{
|
|
// Instantiate ProtoConverter object
|
|
ProtoConverter converter;
|
|
std::string gifRawData = converter.gifProtoToString(gif_proto);
|
|
if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH"))
|
|
{
|
|
// With libFuzzer binary run this to generate a GIF from proto:
|
|
// PROTO_FUZZER_DUMP_PATH=x.gif ./fuzzer proto-input
|
|
std::ofstream of(dump_path);
|
|
of.write(gifRawData.data(), gifRawData.size());
|
|
}
|
|
fuzz_dgif_extended((const uint8_t *)gifRawData.data(), gifRawData.size());
|
|
} |