Coverage Report

Created: 2026-09-02 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cups/ossfuzz/fuzz_ppd_gen_conflicts.c
Line
Count
Source
1
#include <stdint.h>
2
#include <stddef.h>
3
#include "ppd.h"
4
#include "cups.h"
5
#include "file-private.h"
6
7
20.0k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
8
    // Create a temporary file name using process id to avoid conflicts
9
20.0k
    char filename[256];
10
20.0k
    snprintf(filename, sizeof(filename), "/tmp/fuzz_ppd_%d.ppd", getpid());
11
12
    // Write the data to a temporary file
13
20.0k
    FILE *file = fopen(filename, "wb");
14
20.0k
    if (!file) {
15
0
        return 0;
16
0
    }
17
20.0k
    fwrite(data, 1, size, file);
18
20.0k
    fclose(file);
19
20
    // Open the PPD file
21
20.0k
    ppd_file_t *ppd = ppdOpenFile(filename);
22
20.0k
    if (!ppd) {
23
4.52k
        remove(filename);
24
4.52k
        return 0;
25
4.52k
    }
26
27
    // Check for conflicts
28
15.5k
    ppdConflicts(ppd);
29
30
    // Parse options from a sample string
31
15.5k
    cups_option_t *options = NULL;
32
15.5k
    int num_options = cupsParseOptions("SampleOption=SampleValue", 0, &options);
33
34
    // Mark options in the PPD file
35
15.5k
    cupsMarkOptions(ppd, num_options, options);
36
37
    // Check for conflicts with specific options and choices
38
15.5k
    cupsGetConflicts(ppd, "SampleOption", "SampleChoice", &options);
39
40
    // Resolve conflicts with specific options and choices
41
15.5k
    int num_resolved_options = num_options;
42
15.5k
    cupsResolveConflicts(ppd, "SampleOption", "SampleChoice", &num_resolved_options, &options);
43
44
    // Free options
45
15.5k
    cupsFreeOptions(num_options, options);
46
47
    // Close the PPD file
48
15.5k
    ppdClose(ppd);
49
50
    // Remove the temporary file
51
15.5k
    remove(filename);
52
53
15.5k
    return 0;
54
20.0k
}