Coverage Report

Created: 2025-04-22 06:18

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