Coverage Report

Created: 2026-10-28 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/fuzz/pkcs7_verify.c
Line
Count
Source
1
/*
2
 * Copyright 2026 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 * https://www.openssl.org/source/license.html
8
 * or in the file LICENSE in the source distribution.
9
 */
10
#include <limits.h>
11
#include <openssl/bio.h>
12
#include <openssl/err.h>
13
#include <openssl/pkcs7.h>
14
#include "fuzzer.h"
15
16
int FuzzerInitialize(int *argc, char ***argv)
17
254
{
18
254
    return 1;
19
254
}
20
21
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
22
19.8k
{
23
19.8k
    BIO *indata = NULL;
24
19.8k
    BIO *out = NULL;
25
19.8k
    PKCS7 *p7 = NULL;
26
19.8k
    const unsigned char *in;
27
19.8k
    size_t consumed;
28
19.8k
    size_t remaining;
29
30
19.8k
    if (len > LONG_MAX)
31
0
        return 0;
32
33
19.8k
    in = buf;
34
19.8k
    p7 = d2i_PKCS7(NULL, &in, (long)len);
35
19.8k
    if (p7 == NULL)
36
10.9k
        goto err;
37
38
8.85k
    consumed = (size_t)(in - buf);
39
8.85k
    remaining = len - consumed;
40
8.85k
    if (remaining > INT_MAX)
41
0
        goto err;
42
43
8.85k
    if (consumed < len) {
44
7.31k
        indata = BIO_new_mem_buf(in, (int)remaining);
45
7.31k
        if (indata == NULL)
46
0
            goto err;
47
7.31k
    }
48
49
8.85k
    out = BIO_new(BIO_s_null());
50
8.85k
    if (out == NULL)
51
0
        goto err;
52
53
8.85k
    PKCS7_verify(p7, NULL, NULL, indata, out, PKCS7_NOVERIFY);
54
55
19.8k
err:
56
19.8k
    BIO_free(out);
57
19.8k
    PKCS7_free(p7);
58
19.8k
    BIO_free(indata);
59
19.8k
    ERR_clear_error();
60
19.8k
    return 0;
61
8.85k
}
62
63
void FuzzerCleanup(void)
64
0
{
65
0
}