Coverage Report

Created: 2025-08-20 06:31

/src/cups/ossfuzz/fuzz_cups.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Fuzztest for `_cupsRasterExecPS`.
3
 *
4
 * Copyright © 2024 by OpenPrinting.
5
 *
6
 * Licensed under Apache License v2.0.  See the file "LICENSE" for more
7
 * information.
8
 */
9
10
#undef _CUPS_NO_DEPRECATED
11
#include <cups-private.h>
12
#include <ppd-private.h>
13
#include <raster-private.h>
14
15
11.7k
#define kMinInputLength 2
16
5.85k
#define kMaxInputLength 2048
17
18
extern int
19
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
20
5.85k
{
21
5.85k
    int                  p_bits;
22
5.85k
    char                 *data_in;
23
5.85k
    cups_page_header2_t  header;
24
25
5.85k
    if (size < kMinInputLength || size > kMaxInputLength) {
26
23
        return 0;
27
23
    }
28
29
    /* Add NUL byte. */
30
5.82k
    data_in = calloc(size + 1, sizeof(char));
31
5.82k
    if(data_in == NULL) {
32
0
        return 0;
33
0
    }
34
35
5.82k
    memcpy(data_in, data, size);
36
37
5.82k
    memset(&header, 0, sizeof(header));
38
5.82k
    header.Collate = CUPS_TRUE;
39
5.82k
    p_bits = 0;
40
41
5.82k
    _cupsRasterExecPS(&header, &p_bits, data_in);
42
43
5.82k
    free(data_in);
44
5.82k
    return 0;
45
5.82k
}