Coverage Report

Created: 2025-11-09 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cups/ossfuzz/fuzz_ppd_gen_1.c
Line
Count
Source
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <unistd.h>
5
#include "ppd.h"
6
#include "cups.h"
7
#include "file-private.h"
8
9
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
10
18.6k
{
11
    // Create a temporary file to simulate a PPD file
12
18.6k
    char filename[256];
13
18.6k
    snprintf(filename, sizeof(filename), "/tmp/fuzz_ppd_%d.ppd", getpid());
14
15
18.6k
    FILE *file = fopen(filename, "wb");
16
18.6k
    if (!file)
17
0
    {
18
0
        return 0; // Could not create file, exit
19
0
    }
20
21
18.6k
    fwrite(data, 1, size, file);
22
18.6k
    fclose(file);
23
24
    // Open the PPD file
25
18.6k
    ppd_file_t *ppd = ppdOpenFile(filename);
26
18.6k
    if (!ppd)
27
6.29k
    {
28
6.29k
        unlink(filename);
29
6.29k
        return 0; // Could not open PPD file, exit
30
6.29k
    }
31
32
    // Mark default options
33
12.3k
    ppdMarkDefaults(ppd);
34
35
    // Check for conflicts
36
12.3k
    int conflicts = ppdConflicts(ppd);
37
38
    // Optionally mark options (using dummy options for demonstration)
39
12.3k
    cups_option_t options[1];
40
12.3k
    options[0].name = "OptionName";
41
12.3k
    options[0].value = "OptionValue";
42
12.3k
    cupsMarkOptions(ppd, 1, options);
43
44
    // Close the PPD file
45
12.3k
    ppdClose(ppd);
46
47
    // Clean up the temporary file
48
12.3k
    unlink(filename);
49
50
12.3k
    return 0;
51
18.6k
}