Coverage Report

Created: 2023-06-08 06:41

/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
308k
{
15
308k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
16
308k
    if (es->top == es->bottom)
17
0
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
18
308k
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
14
308k
{
15
308k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
16
308k
    if (es->top == es->bottom)
17
0
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
18
308k
}
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
1.37M
{
22
1.37M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
1.01M
        if (deall) {
24
10
            OPENSSL_free(es->err_data[i]);
25
10
            es->err_data[i] = NULL;
26
10
            es->err_data_size[i] = 0;
27
10
            es->err_data_flags[i] = 0;
28
1.01M
        } else if (es->err_data[i] != NULL) {
29
1.01M
            es->err_data[i][0] = '\0';
30
1.01M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
1.01M
        }
32
1.01M
    } else {
33
353k
        es->err_data[i] = NULL;
34
353k
        es->err_data_size[i] = 0;
35
353k
        es->err_data_flags[i] = 0;
36
353k
    }
37
1.37M
}
err.c:err_clear_data
Line
Count
Source
21
754k
{
22
754k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
481k
        if (deall) {
24
10
            OPENSSL_free(es->err_data[i]);
25
10
            es->err_data[i] = NULL;
26
10
            es->err_data_size[i] = 0;
27
10
            es->err_data_flags[i] = 0;
28
481k
        } else if (es->err_data[i] != NULL) {
29
481k
            es->err_data[i][0] = '\0';
30
481k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
481k
        }
32
481k
    } else {
33
272k
        es->err_data[i] = NULL;
34
272k
        es->err_data_size[i] = 0;
35
272k
        es->err_data_flags[i] = 0;
36
272k
    }
37
754k
}
err_blocks.c:err_clear_data
Line
Count
Source
21
616k
{
22
616k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
536k
        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
536k
        } else if (es->err_data[i] != NULL) {
29
536k
            es->err_data[i][0] = '\0';
30
536k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
536k
        }
32
536k
    } else {
33
80.8k
        es->err_data[i] = NULL;
34
80.8k
        es->err_data_size[i] = 0;
35
80.8k
        es->err_data_flags[i] = 0;
36
80.8k
    }
37
616k
}
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
308k
{
42
308k
    es->err_buffer[i] =
43
308k
        lib == ERR_LIB_SYS
44
308k
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
45
308k
        : ERR_PACK(lib, 0, reason);
46
308k
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
41
308k
{
42
308k
    es->err_buffer[i] =
43
308k
        lib == ERR_LIB_SYS
44
308k
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
45
308k
        : ERR_PACK(lib, 0, reason);
46
308k
}
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
308k
{
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
308k
    OPENSSL_free(es->err_file[i]);
57
308k
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
308k
    else
60
308k
        es->err_file[i] = OPENSSL_strdup(file);
61
308k
    es->err_line[i] = line;
62
308k
    OPENSSL_free(es->err_func[i]);
63
308k
    if (fn == NULL || fn[0] == '\0')
64
0
        es->err_func[i] = NULL;
65
308k
    else
66
308k
        es->err_func[i] = OPENSSL_strdup(fn);
67
308k
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
51
308k
{
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
308k
    OPENSSL_free(es->err_file[i]);
57
308k
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
308k
    else
60
308k
        es->err_file[i] = OPENSSL_strdup(file);
61
308k
    es->err_line[i] = line;
62
308k
    OPENSSL_free(es->err_func[i]);
63
308k
    if (fn == NULL || fn[0] == '\0')
64
0
        es->err_func[i] = NULL;
65
308k
    else
66
308k
        es->err_func[i] = OPENSSL_strdup(fn);
67
308k
}
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
81.0k
{
72
81.0k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
768
        OPENSSL_free(es->err_data[i]);
74
81.0k
    es->err_data[i] = data;
75
81.0k
    es->err_data_size[i] = datasz;
76
81.0k
    es->err_data_flags[i] = flags;
77
81.0k
}
err.c:err_set_data
Line
Count
Source
71
776
{
72
776
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
768
        OPENSSL_free(es->err_data[i]);
74
776
    es->err_data[i] = data;
75
776
    es->err_data_size[i] = datasz;
76
776
    es->err_data_flags[i] = flags;
77
776
}
err_blocks.c:err_set_data
Line
Count
Source
71
80.3k
{
72
80.3k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
0
        OPENSSL_free(es->err_data[i]);
74
80.3k
    es->err_data[i] = data;
75
80.3k
    es->err_data_size[i] = datasz;
76
80.3k
    es->err_data_flags[i] = flags;
77
80.3k
}
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
1.06M
{
81
1.06M
    err_clear_data(es, i, (deall));
82
1.06M
    es->err_marks[i] = 0;
83
1.06M
    es->err_flags[i] = 0;
84
1.06M
    es->err_buffer[i] = 0;
85
1.06M
    es->err_line[i] = -1;
86
1.06M
    OPENSSL_free(es->err_file[i]);
87
1.06M
    es->err_file[i] = NULL;
88
1.06M
    OPENSSL_free(es->err_func[i]);
89
1.06M
    es->err_func[i] = NULL;
90
1.06M
}
err.c:err_clear
Line
Count
Source
80
753k
{
81
753k
    err_clear_data(es, i, (deall));
82
753k
    es->err_marks[i] = 0;
83
753k
    es->err_flags[i] = 0;
84
753k
    es->err_buffer[i] = 0;
85
753k
    es->err_line[i] = -1;
86
753k
    OPENSSL_free(es->err_file[i]);
87
753k
    es->err_file[i] = NULL;
88
753k
    OPENSSL_free(es->err_func[i]);
89
753k
    es->err_func[i] = NULL;
90
753k
}
err_blocks.c:err_clear
Line
Count
Source
80
308k
{
81
308k
    err_clear_data(es, i, (deall));
82
308k
    es->err_marks[i] = 0;
83
308k
    es->err_flags[i] = 0;
84
308k
    es->err_buffer[i] = 0;
85
308k
    es->err_line[i] = -1;
86
308k
    OPENSSL_free(es->err_file[i]);
87
308k
    es->err_file[i] = NULL;
88
308k
    OPENSSL_free(es->err_func[i]);
89
308k
    es->err_func[i] = NULL;
90
308k
}
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);