Coverage Report

Created: 2023-09-25 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
173k
{
15
173k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
16
173k
    if (es->top == es->bottom)
17
333
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
18
173k
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
14
173k
{
15
173k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
16
173k
    if (es->top == es->bottom)
17
333
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
18
173k
}
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
765k
{
22
765k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
568k
        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
568k
        } else if (es->err_data[i] != NULL) {
29
568k
            es->err_data[i][0] = '\0';
30
568k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
568k
        }
32
568k
    } else {
33
197k
        es->err_data[i] = NULL;
34
197k
        es->err_data_size[i] = 0;
35
197k
        es->err_data_flags[i] = 0;
36
197k
    }
37
765k
}
err.c:err_clear_data
Line
Count
Source
21
418k
{
22
418k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
335k
        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
335k
        } else if (es->err_data[i] != NULL) {
29
335k
            es->err_data[i][0] = '\0';
30
335k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
335k
        }
32
335k
    } else {
33
83.1k
        es->err_data[i] = NULL;
34
83.1k
        es->err_data_size[i] = 0;
35
83.1k
        es->err_data_flags[i] = 0;
36
83.1k
    }
37
418k
}
err_blocks.c:err_clear_data
Line
Count
Source
21
346k
{
22
346k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
23
232k
        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
232k
        } else if (es->err_data[i] != NULL) {
29
232k
            es->err_data[i][0] = '\0';
30
232k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
31
232k
        }
32
232k
    } else {
33
114k
        es->err_data[i] = NULL;
34
114k
        es->err_data_size[i] = 0;
35
114k
        es->err_data_flags[i] = 0;
36
114k
    }
37
346k
}
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
173k
{
42
173k
    es->err_buffer[i] =
43
173k
        lib == ERR_LIB_SYS
44
173k
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
45
173k
        : ERR_PACK(lib, 0, reason);
46
173k
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
41
173k
{
42
173k
    es->err_buffer[i] =
43
173k
        lib == ERR_LIB_SYS
44
173k
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
45
173k
        : ERR_PACK(lib, 0, reason);
46
173k
}
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
173k
{
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
173k
    OPENSSL_free(es->err_file[i]);
57
173k
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
173k
    else
60
173k
        es->err_file[i] = OPENSSL_strdup(file);
61
173k
    es->err_line[i] = line;
62
173k
    OPENSSL_free(es->err_func[i]);
63
173k
    if (fn == NULL || fn[0] == '\0')
64
0
        es->err_func[i] = NULL;
65
173k
    else
66
173k
        es->err_func[i] = OPENSSL_strdup(fn);
67
173k
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
51
173k
{
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
173k
    OPENSSL_free(es->err_file[i]);
57
173k
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
173k
    else
60
173k
        es->err_file[i] = OPENSSL_strdup(file);
61
173k
    es->err_line[i] = line;
62
173k
    OPENSSL_free(es->err_func[i]);
63
173k
    if (fn == NULL || fn[0] == '\0')
64
0
        es->err_func[i] = NULL;
65
173k
    else
66
173k
        es->err_func[i] = OPENSSL_strdup(fn);
67
173k
}
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
118k
{
72
118k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
5.70k
        OPENSSL_free(es->err_data[i]);
74
118k
    es->err_data[i] = data;
75
118k
    es->err_data_size[i] = datasz;
76
118k
    es->err_data_flags[i] = flags;
77
118k
}
err.c:err_set_data
Line
Count
Source
71
5.71k
{
72
5.71k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
5.70k
        OPENSSL_free(es->err_data[i]);
74
5.71k
    es->err_data[i] = data;
75
5.71k
    es->err_data_size[i] = datasz;
76
5.71k
    es->err_data_flags[i] = flags;
77
5.71k
}
err_blocks.c:err_set_data
Line
Count
Source
71
112k
{
72
112k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
73
0
        OPENSSL_free(es->err_data[i]);
74
112k
    es->err_data[i] = data;
75
112k
    es->err_data_size[i] = datasz;
76
112k
    es->err_data_flags[i] = flags;
77
112k
}
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
586k
{
81
586k
    err_clear_data(es, i, (deall));
82
586k
    es->err_marks[i] = 0;
83
586k
    es->err_flags[i] = 0;
84
586k
    es->err_buffer[i] = 0;
85
586k
    es->err_line[i] = -1;
86
586k
    OPENSSL_free(es->err_file[i]);
87
586k
    es->err_file[i] = NULL;
88
586k
    OPENSSL_free(es->err_func[i]);
89
586k
    es->err_func[i] = NULL;
90
586k
}
err.c:err_clear
Line
Count
Source
80
413k
{
81
413k
    err_clear_data(es, i, (deall));
82
413k
    es->err_marks[i] = 0;
83
413k
    es->err_flags[i] = 0;
84
413k
    es->err_buffer[i] = 0;
85
413k
    es->err_line[i] = -1;
86
413k
    OPENSSL_free(es->err_file[i]);
87
413k
    es->err_file[i] = NULL;
88
413k
    OPENSSL_free(es->err_func[i]);
89
413k
    es->err_func[i] = NULL;
90
413k
}
err_blocks.c:err_clear
Line
Count
Source
80
173k
{
81
173k
    err_clear_data(es, i, (deall));
82
173k
    es->err_marks[i] = 0;
83
173k
    es->err_flags[i] = 0;
84
173k
    es->err_buffer[i] = 0;
85
173k
    es->err_line[i] = -1;
86
173k
    OPENSSL_free(es->err_file[i]);
87
173k
    es->err_file[i] = NULL;
88
173k
    OPENSSL_free(es->err_func[i]);
89
173k
    es->err_func[i] = NULL;
90
173k
}
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);