Coverage Report

Created: 2024-10-08 22:36

/src/bag/fuzzers/bag_read_fuzzer.cpp
Line
Count
Source (jump to first uncovered line)
1
#include <stddef.h>
2
#include <stdint.h>
3
#include <unistd.h>
4
5
#include "bag_dataset.h"
6
7
using BAG::Dataset;
8
9
10
330
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
11
12
330
    char filename[256];
13
330
    snprintf(filename, 255, "/tmp/libfuzzer.%d", getpid());
14
15
    // Save input file to temporary file so that we can read it.
16
330
    FILE *fp = fopen(filename, "wb");
17
330
    if (!fp) {
18
0
        return 0;
19
0
    }
20
330
    fwrite(buf, len, 1, fp);
21
330
    fclose(fp);
22
23
330
    auto pDataset = Dataset::open(filename, BAG_OPEN_READONLY);
24
330
    if (pDataset != NULL) {
25
180
        pDataset->close();
26
180
    }
27
28
330
    return 0;
29
330
}