/src/dgif_protobuf_target.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdlib.h> |
2 | | #include <stdint.h> |
3 | | #include <string.h> |
4 | | #include <string> |
5 | | #include <sstream> |
6 | | #include <fstream> |
7 | | #include "dgif_fuzz_common.h" |
8 | | |
9 | | #include "libprotobuf-mutator/src/libfuzzer/libfuzzer_macro.h" |
10 | | #include "ProtoToGif.h" |
11 | | |
12 | | using namespace gifProtoFuzzer; |
13 | | |
14 | | DEFINE_PROTO_FUZZER(const GifProto &gif_proto) |
15 | 960 | { |
16 | | // Instantiate ProtoConverter object |
17 | 960 | ProtoConverter converter; |
18 | 960 | std::string gifRawData = converter.gifProtoToString(gif_proto); |
19 | 960 | if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) |
20 | 0 | { |
21 | | // With libFuzzer binary run this to generate a GIF from proto: |
22 | | // PROTO_FUZZER_DUMP_PATH=x.gif ./fuzzer proto-input |
23 | 0 | std::ofstream of(dump_path); |
24 | 0 | of.write(gifRawData.data(), gifRawData.size()); |
25 | 0 | } |
26 | 960 | fuzz_dgif_extended((const uint8_t *)gifRawData.data(), gifRawData.size()); |
27 | 960 | } |