Coverage Report

Created: 2026-11-12 06:52

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
20.4k
{
11
    // Create a temporary file to simulate a PPD file
12
20.4k
    char filename[256];
13
20.4k
    snprintf(filename, sizeof(filename), "/tmp/fuzz_ppd_%d.ppd", getpid());
14
15
20.4k
    FILE *file = fopen(filename, "wb");
16
20.4k
    if (!file)
17
0
    {
18
0
        return 0; // Could not create file, exit
19
0
    }
20
21
20.4k
    fwrite(data, 1, size, file);
22
20.4k
    fclose(file);
23
24
    // Open the PPD file
25
20.4k
    ppd_file_t *ppd = ppdOpenFile(filename);
26
20.4k
    if (!ppd)
27
4.25k
    {
28
4.25k
        unlink(filename);
29
4.25k
        return 0; // Could not open PPD file, exit
30
4.25k
    }
31
32
    // Mark default options
33
16.1k
    ppdMarkDefaults(ppd);
34
35
    // Check for conflicts
36
16.1k
    int conflicts = ppdConflicts(ppd);
37
38
    // Optionally mark options (using dummy options for demonstration)
39
16.1k
    cups_option_t options[1];
40
16.1k
    options[0].name = "OptionName";
41
16.1k
    options[0].value = "OptionValue";
42
16.1k
    cupsMarkOptions(ppd, 1, options);
43
44
    // Close the PPD file
45
16.1k
    ppdClose(ppd);
46
47
    // Clean up the temporary file
48
16.1k
    unlink(filename);
49
50
16.1k
    return 0;
51
20.4k
}