Coverage Report

Created: 2025-06-13 06:58

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