blob: d62fff5811ec8e20b7af80dc65412eb555bd4c18 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include "packeteer/pcapng/reader.hpp"
// Reader parses file/network data that isn't necessarily our own
// writer's output - a user could point it at any file. fmemopen()
// gives libFuzzer's byte buffer a FILE* without touching a real file.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
FILE* file = fmemopen(const_cast<uint8_t*>(data), size, "rb");
if (file == nullptr) return 0;
packeteer::pcapng::Reader reader(file);
while (reader.next_packet()) {
// keep draining until EOF/malformed-block termination
}
std::fclose(file);
return 0;
}
|