Coverage Report

Created: 2023-09-25 06:45

/src/openssl30/crypto/err/err_local.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 1995-2021 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/err.h>
11
#include <openssl/e_os2.h>
12
13
static ossl_inline void err_get_slot(ERR_STATE *es)
14
65.6M
{
15
65.6M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
16
65.6M
    if (es->top == es->bottom)
17
10.6M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
18
65.6M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
14
65.6M
{
15
65.6M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
16
65.6M
    if (es->top == es->bottom)
17
10.6M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
18
65.6M
}
Unexecuted instantiation: err_prn.c:err_get_slot
19
20
static ossl_inline void err_clear_data(ERR_STATE *es, size_t i, int deall)
21
169M
{
22
169M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
167M
        if (deall) {
24
303
            OPENSSL_free(es->err_data[i]);
25
303
            es->err_data[i] = NULL;
26
303
            es->err_data_size[i] = 0;
27
303
            es->err_data_flags[i] = 0;
28
167M
        } else if (es->err_data[i] != NULL) {
29
167M
            es->err_data[i][0] = '\0';
30
167M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
167M
        }
32
167M
    } else {
33
2.14M
        es->err_data[i] = NULL;
34
2.14M
        es->err_data_size[i] = 0;
35
2.14M
        es->err_data_flags[i] = 0;
36
2.14M
    }
37
169M
}
err.c:err_clear_data
Line
Count
Source
21
38.5M
{
22
38.5M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
37.2M
        if (deall) {
24
303
            OPENSSL_free(es->err_data[i]);
25
303
            es->err_data[i] = NULL;
26
303
            es->err_data_size[i] = 0;
27
303
            es->err_data_flags[i] = 0;
28
37.2M
        } else if (es->err_data[i] != NULL) {
29
37.2M
            es->err_data[i][0] = '\0';
30
37.2M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
37.2M
        }
32
37.2M
    } else {
33
1.35M
        es->err_data[i] = NULL;
34
1.35M
        es->err_data_size[i] = 0;
35
1.35M
        es->err_data_flags[i] = 0;
36
1.35M
    }
37
38.5M
}
err_blocks.c:err_clear_data
Line
Count
Source
21
131M
{
22
131M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
130M
        if (deall) {
24
0
            OPENSSL_free(es->err_data[i]);
25
0
            es->err_data[i] = NULL;
26
0
            es->err_data_size[i] = 0;
27
0
            es->err_data_flags[i] = 0;
28
130M
        } else if (es->err_data[i] != NULL) {
29
130M
            es->err_data[i][0] = '\0';
30
130M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
130M
        }
32
130M
    } else {
33
795k
        es->err_data[i] = NULL;
34
795k
        es->err_data_size[i] = 0;
35
795k
        es->err_data_flags[i] = 0;
36
795k
    }
37
131M
}
Unexecuted instantiation: err_prn.c:err_clear_data
38
39
static ossl_inline void err_set_error(ERR_STATE *es, size_t i,
40
                                      int lib, int reason)
41
65.6M
{
42
65.6M
    es->err_buffer[i] =
43
65.6M
        lib == ERR_LIB_SYS
44
65.6M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
45
65.6M
        : ERR_PACK(lib, 0, reason);
46
65.6M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
41
65.6M
{
42
65.6M
    es->err_buffer[i] =
43
65.6M
        lib == ERR_LIB_SYS
44
65.6M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
45
65.6M
        : ERR_PACK(lib, 0, reason);
46
65.6M
}
Unexecuted instantiation: err_prn.c:err_set_error
47
48
static ossl_inline void err_set_debug(ERR_STATE *es, size_t i,
49
                                      const char *file, int line,
50
                                      const char *fn)
51
35.2M
{
52
    /*
53
     * We dup the file and fn strings because they may be provider owned. If the
54
     * provider gets unloaded, they may not be valid anymore.
55
     */
56
35.2M
    OPENSSL_free(es->err_file[i]);
57
35.2M
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
35.2M
    else
60
35.2M
        es->err_file[i] = OPENSSL_strdup(file);
61
35.2M
    es->err_line[i] = line;
62
35.2M
    OPENSSL_free(es->err_func[i]);
63
35.2M
    if (fn == NULL || fn[0] == '\0')
64
0
        es->err_func[i] = NULL;
65
35.2M
    else
66
35.2M
        es->err_func[i] = OPENSSL_strdup(fn);
67
35.2M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
51
35.2M
{
52
    /*
53
     * We dup the file and fn strings because they may be provider owned. If the
54
     * provider gets unloaded, they may not be valid anymore.
55
     */
56
35.2M
    OPENSSL_free(es->err_file[i]);
57
35.2M
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
35.2M
    else
60
35.2M
        es->err_file[i] = OPENSSL_strdup(file);
61
35.2M
    es->err_line[i] = line;
62
35.2M
    OPENSSL_free(es->err_func[i]);
63
35.2M
    if (fn == NULL || fn[0] == '\0')
64
0
        es->err_func[i] = NULL;
65
35.2M
    else
66
35.2M
        es->err_func[i] = OPENSSL_strdup(fn);
67
35.2M
}
Unexecuted instantiation: err_prn.c:err_set_debug
68
69
static ossl_inline void err_set_data(ERR_STATE *es, size_t i,
70
                                     void *data, size_t datasz, int flags)
71
5.99M
{
72
5.99M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
5.31M
        OPENSSL_free(es->err_data[i]);
74
5.99M
    es->err_data[i] = data;
75
5.99M
    es->err_data_size[i] = datasz;
76
5.99M
    es->err_data_flags[i] = flags;
77
5.99M
}
err.c:err_set_data
Line
Count
Source
71
5.31M
{
72
5.31M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
5.31M
        OPENSSL_free(es->err_data[i]);
74
5.31M
    es->err_data[i] = data;
75
5.31M
    es->err_data_size[i] = datasz;
76
5.31M
    es->err_data_flags[i] = flags;
77
5.31M
}
err_blocks.c:err_set_data
Line
Count
Source
71
680k
{
72
680k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
0
        OPENSSL_free(es->err_data[i]);
74
680k
    es->err_data[i] = data;
75
680k
    es->err_data_size[i] = datasz;
76
680k
    es->err_data_flags[i] = flags;
77
680k
}
Unexecuted instantiation: err_prn.c:err_set_data
78
79
static ossl_inline void err_clear(ERR_STATE *es, size_t i, int deall)
80
98.8M
{
81
98.8M
    err_clear_data(es, i, (deall));
82
98.8M
    es->err_marks[i] = 0;
83
98.8M
    es->err_flags[i] = 0;
84
98.8M
    es->err_buffer[i] = 0;
85
98.8M
    es->err_line[i] = -1;
86
98.8M
    OPENSSL_free(es->err_file[i]);
87
98.8M
    es->err_file[i] = NULL;
88
98.8M
    OPENSSL_free(es->err_func[i]);
89
98.8M
    es->err_func[i] = NULL;
90
98.8M
}
err.c:err_clear
Line
Count
Source
80
33.2M
{
81
33.2M
    err_clear_data(es, i, (deall));
82
33.2M
    es->err_marks[i] = 0;
83
33.2M
    es->err_flags[i] = 0;
84
33.2M
    es->err_buffer[i] = 0;
85
33.2M
    es->err_line[i] = -1;
86
33.2M
    OPENSSL_free(es->err_file[i]);
87
33.2M
    es->err_file[i] = NULL;
88
33.2M
    OPENSSL_free(es->err_func[i]);
89
33.2M
    es->err_func[i] = NULL;
90
33.2M
}
err_blocks.c:err_clear
Line
Count
Source
80
65.6M
{
81
65.6M
    err_clear_data(es, i, (deall));
82
65.6M
    es->err_marks[i] = 0;
83
65.6M
    es->err_flags[i] = 0;
84
65.6M
    es->err_buffer[i] = 0;
85
65.6M
    es->err_line[i] = -1;
86
65.6M
    OPENSSL_free(es->err_file[i]);
87
65.6M
    es->err_file[i] = NULL;
88
65.6M
    OPENSSL_free(es->err_func[i]);
89
65.6M
    es->err_func[i] = NULL;
90
65.6M
}
Unexecuted instantiation: err_prn.c:err_clear
91
92
ERR_STATE *ossl_err_get_state_int(void);
93
void ossl_err_string_int(unsigned long e, const char *func,
94
                         char *buf, size_t len);