Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/fuzz/smime.c
Line
Count
Source
1
/*
2
 * Copyright 2023-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
11
#include "fuzzer.h"
12
#include <openssl/err.h>
13
#include <openssl/pkcs7.h>
14
#include <openssl/x509.h>
15
#include <stdio.h>
16
17
int FuzzerInitialize(int *argc, char ***argv)
18
229
{
19
229
    return 1;
20
229
}
21
22
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
23
4.57k
{
24
4.57k
    BIO *b;
25
4.57k
    PKCS7 *p7;
26
27
4.57k
    if (len > INT_MAX)
28
0
        return 0;
29
30
4.57k
    b = BIO_new_mem_buf(buf, (int)len);
31
4.57k
    if (b == NULL) {
32
0
        ERR_clear_error();
33
0
        return 0;
34
0
    }
35
4.57k
    p7 = SMIME_read_PKCS7(b, NULL);
36
37
4.57k
    if (p7 != NULL) {
38
158
        STACK_OF(PKCS7_SIGNER_INFO) *p7si = PKCS7_get_signer_info(p7);
39
158
        int i;
40
41
189
        for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(p7si); i++) {
42
31
            STACK_OF(X509_ALGOR) *algs;
43
44
31
            PKCS7_cert_from_signer_info(p7,
45
31
                sk_PKCS7_SIGNER_INFO_value(p7si, i));
46
31
            algs = PKCS7_get_smimecap(sk_PKCS7_SIGNER_INFO_value(p7si, i));
47
31
            sk_X509_ALGOR_pop_free(algs, X509_ALGOR_free);
48
31
        }
49
158
        PKCS7_free(p7);
50
158
    }
51
52
4.57k
    BIO_free(b);
53
4.57k
    ERR_clear_error();
54
4.57k
    return 0;
55
4.57k
}
56
57
void FuzzerCleanup(void)
58
0
{
59
0
}