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