Coverage Report

Created: 2023-06-08 06:40

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