Coverage Report

Created: 2024-11-04 06:35

/src/cups/ossfuzz/fuzz_helpers.cpp
Line
Count
Source (jump to first uncovered line)
1
// Provide input for C based harnesses
2
3
#include <fuzzer/FuzzedDataProvider.h>
4
5
extern "C" {
6
7
    // For fuzz_array
8
9
    struct FuzzArray {
10
        char* str1;
11
        char* str2;
12
    };
13
14
0
    void generate_fuzz_array_data(const uint8_t *data, size_t size, FuzzArray *outData) {
15
16
0
    FuzzedDataProvider fuzz_data(data, size);
17
0
    std::string fuzz_str1 = fuzz_data.ConsumeRandomLengthString(1);
18
0
    std::string fuzz_str2 = fuzz_data.ConsumeRandomLengthString(1);
19
    // int num = fuzz_data.ConsumeIntegral<int>();
20
21
0
    outData->str1 = new char[fuzz_str1.length() + 1];
22
0
    std::strcpy(outData->str1, fuzz_str1.c_str());
23
24
0
    outData->str2 = new char[fuzz_str2.length() + 1];
25
0
    std::strcpy(outData->str2, fuzz_str2.c_str());
26
    // outData->num = num;
27
0
    }
28
29
0
    void free_fuzz_array_data(FuzzArray *data) {
30
0
        delete[] data->str1;
31
0
        delete[] data->str2;
32
0
    }
33
34
}