Coverage Report

Created: 2026-01-10 06:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cups/ossfuzz/fuzz_ipp.c
Line
Count
Source
1
/*
2
 * Fuzztest for `ippReadIO`.
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
#include <file.h>
11
#include <string-private.h>
12
#include <ipp-private.h>
13
14
5.18k
#define kMinInputLength 2
15
2.59k
#define kMaxInputLength 1024
16
17
void load_ipp(char *file);
18
19
extern int
20
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
21
2.59k
{
22
2.59k
    FILE  *fp;
23
2.59k
    char  file_name[256];
24
25
2.59k
    if (size < kMinInputLength || size > kMaxInputLength) {
26
27
      return 0;
27
27
    }
28
29
2.59k
    sprintf(file_name, "/tmp/libfuzzer.%d", getpid());
30
31
2.56k
    fp = fopen(file_name, "w");
32
2.56k
    if (fp == NULL) {
33
0
        return 0;
34
0
    }
35
36
2.56k
    fwrite(data, sizeof(char), size, fp);
37
2.56k
    fclose(fp);
38
39
2.56k
    load_ipp(file_name);
40
2.56k
    unlink(file_name);
41
42
2.56k
    return 0;
43
2.56k
}
44
45
void load_ipp(char *file)
46
1.95k
{
47
1.95k
    ipp_t    *request;
48
1.95k
    cups_file_t  *fp;
49
50
1.95k
    fp = cupsFileOpen(file, "r");
51
1.95k
    if (fp == NULL) {
52
0
        return;
53
0
    }
54
55
1.95k
    request = ippNew();
56
57
1.95k
    ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, request);
58
59
1.95k
    cupsFileClose(fp);
60
1.95k
    ippDelete(request);
61
1.95k
}