Coverage Report

Created: 2025-11-16 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl34/crypto/x509/v3_usernotice.c
Line
Count
Source
1
/*
2
 * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#include <openssl/asn1t.h>
11
#include <openssl/x509v3.h>
12
#include "ext_dat.h"
13
14
ASN1_ITEM_TEMPLATE(OSSL_USER_NOTICE_SYNTAX) =
15
    ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_USER_NOTICE_SYNTAX, USERNOTICE)
16
16.2k
ASN1_ITEM_TEMPLATE_END(OSSL_USER_NOTICE_SYNTAX)
17
18
IMPLEMENT_ASN1_FUNCTIONS(OSSL_USER_NOTICE_SYNTAX)
19
20
static int print_notice(BIO *out, USERNOTICE *notice, int indent)
21
5.41k
{
22
5.41k
    int i;
23
5.41k
    ASN1_INTEGER *num;
24
5.41k
    char *tmp;
25
26
5.41k
    if (notice->noticeref) {
27
110
        NOTICEREF *ref;
28
110
        ref = notice->noticeref;
29
110
        if (BIO_printf(out, "%*sOrganization: %.*s\n", indent, "",
30
110
                   ref->organization->length,
31
110
                   ref->organization->data) <= 0)
32
0
            return 0;
33
110
        if (BIO_printf(out, "%*sNumber%s: ", indent, "",
34
110
                   sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : "") <= 0)
35
0
            return 0;
36
230
        for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) {
37
120
            num = sk_ASN1_INTEGER_value(ref->noticenos, i);
38
120
            if (i && BIO_puts(out, ", ") <= 0)
39
0
                return 0;
40
120
            if (num == NULL && BIO_puts(out, "(null)") <= 0)
41
0
                return 0;
42
120
            else {
43
120
                tmp = i2s_ASN1_INTEGER(NULL, num);
44
120
                if (tmp == NULL)
45
0
                    return 0;
46
120
                if (BIO_puts(out, tmp) <= 0) {
47
0
                    OPENSSL_free(tmp);
48
0
                    return 0;
49
0
                }
50
120
                OPENSSL_free(tmp);
51
120
            }
52
120
        }
53
110
        if (notice->exptext && BIO_puts(out, "\n") <= 0)
54
0
            return 0;
55
110
    }
56
5.41k
    if (notice->exptext == NULL)
57
4.62k
        return 1;
58
59
793
    return BIO_printf(out, "%*sExplicit Text: %.*s", indent, "",
60
793
                notice->exptext->length,
61
793
                notice->exptext->data) >= 0;
62
5.41k
}
63
64
static int i2r_USER_NOTICE_SYNTAX(X509V3_EXT_METHOD *method,
65
                                  OSSL_USER_NOTICE_SYNTAX *uns,
66
                                  BIO *out, int indent)
67
4.12k
{
68
4.12k
    int i;
69
4.12k
    USERNOTICE *unotice;
70
71
4.12k
    if (BIO_printf(out, "%*sUser Notices:\n", indent, "") <= 0)
72
0
        return 0;
73
74
9.53k
    for (i = 0; i < sk_USERNOTICE_num(uns); i++) {
75
5.41k
        unotice = sk_USERNOTICE_value(uns, i);
76
5.41k
        if (!print_notice(out, unotice, indent + 4))
77
0
            return 0;
78
5.41k
        if (BIO_puts(out, "\n\n") <= 0)
79
0
            return 0;
80
5.41k
    }
81
4.12k
    return 1;
82
4.12k
}
83
84
const X509V3_EXT_METHOD ossl_v3_user_notice = {
85
    NID_user_notice, 0,
86
    ASN1_ITEM_ref(OSSL_USER_NOTICE_SYNTAX),
87
    0, 0, 0, 0,
88
    0,
89
    0,
90
    0, 0,
91
    (X509V3_EXT_I2R)i2r_USER_NOTICE_SYNTAX,
92
    0,
93
    NULL
94
};