Coverage Report

Created: 2025-07-18 07:04

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