Coverage Report

Created: 2025-12-04 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/crypto/err/err_local.h
Line
Count
Source
1
/*
2
 * Copyright 1995-2023 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 <string.h>
11
#include <openssl/err.h>
12
#include <openssl/e_os2.h>
13
14
static ossl_inline void err_get_slot(ERR_STATE *es)
15
289M
{
16
289M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
289M
    if (es->top == es->bottom)
18
36.6M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
289M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
15
289M
{
16
289M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
289M
    if (es->top == es->bottom)
18
36.5M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
289M
}
Unexecuted instantiation: err_mark.c:err_get_slot
err_save.c:err_get_slot
Line
Count
Source
15
61.6k
{
16
61.6k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
61.6k
    if (es->top == es->bottom)
18
5.59k
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
61.6k
}
Unexecuted instantiation: err_prn.c:err_get_slot
20
21
static ossl_inline void err_clear_data(ERR_STATE *es, size_t i, int deall)
22
1.91G
{
23
1.91G
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
927M
        if (deall) {
25
75.8k
            OPENSSL_free(es->err_data[i]);
26
75.8k
            es->err_data[i] = NULL;
27
75.8k
            es->err_data_size[i] = 0;
28
75.8k
            es->err_data_flags[i] = 0;
29
927M
        } else if (es->err_data[i] != NULL) {
30
927M
            es->err_data[i][0] = '\0';
31
927M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
927M
        }
33
990M
    } else {
34
990M
        es->err_data[i] = NULL;
35
990M
        es->err_data_size[i] = 0;
36
990M
        es->err_data_flags[i] = 0;
37
990M
    }
38
1.91G
}
err.c:err_clear_data
Line
Count
Source
22
1.11G
{
23
1.11G
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
131M
        if (deall) {
25
75.8k
            OPENSSL_free(es->err_data[i]);
26
75.8k
            es->err_data[i] = NULL;
27
75.8k
            es->err_data_size[i] = 0;
28
75.8k
            es->err_data_flags[i] = 0;
29
131M
        } else if (es->err_data[i] != NULL) {
30
131M
            es->err_data[i][0] = '\0';
31
131M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
131M
        }
33
984M
    } else {
34
        es->err_data[i] = NULL;
35
984M
        es->err_data_size[i] = 0;
36
984M
        es->err_data_flags[i] = 0;
37
984M
    }
38
1.11G
}
err_blocks.c:err_clear_data
Line
Count
Source
22
578M
{
23
578M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
573M
        if (deall) {
25
0
            OPENSSL_free(es->err_data[i]);
26
0
            es->err_data[i] = NULL;
27
0
            es->err_data_size[i] = 0;
28
0
            es->err_data_flags[i] = 0;
29
573M
        } else if (es->err_data[i] != NULL) {
30
573M
            es->err_data[i][0] = '\0';
31
573M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
573M
        }
33
573M
    } else {
34
        es->err_data[i] = NULL;
35
5.21M
        es->err_data_size[i] = 0;
36
5.21M
        es->err_data_flags[i] = 0;
37
5.21M
    }
38
578M
}
err_mark.c:err_clear_data
Line
Count
Source
22
223M
{
23
223M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
222M
        if (deall) {
25
0
            OPENSSL_free(es->err_data[i]);
26
0
            es->err_data[i] = NULL;
27
0
            es->err_data_size[i] = 0;
28
0
            es->err_data_flags[i] = 0;
29
222M
        } else if (es->err_data[i] != NULL) {
30
222M
            es->err_data[i][0] = '\0';
31
222M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
222M
        }
33
222M
    } else {
34
        es->err_data[i] = NULL;
35
488k
        es->err_data_size[i] = 0;
36
488k
        es->err_data_flags[i] = 0;
37
488k
    }
38
223M
}
err_save.c:err_clear_data
Line
Count
Source
22
697k
{
23
697k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
4.63k
        if (deall) {
25
0
            OPENSSL_free(es->err_data[i]);
26
0
            es->err_data[i] = NULL;
27
0
            es->err_data_size[i] = 0;
28
0
            es->err_data_flags[i] = 0;
29
4.63k
        } else if (es->err_data[i] != NULL) {
30
4.63k
            es->err_data[i][0] = '\0';
31
4.63k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
4.63k
        }
33
692k
    } else {
34
        es->err_data[i] = NULL;
35
692k
        es->err_data_size[i] = 0;
36
692k
        es->err_data_flags[i] = 0;
37
692k
    }
38
697k
}
Unexecuted instantiation: err_prn.c:err_clear_data
39
40
static ossl_inline void err_set_error(ERR_STATE *es, size_t i,
41
                                      int lib, int reason)
42
289M
{
43
289M
    es->err_buffer[i] =
44
289M
        lib == ERR_LIB_SYS
45
289M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
289M
        : ERR_PACK(lib, 0, reason);
47
289M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
42
289M
{
43
289M
    es->err_buffer[i] =
44
289M
        lib == ERR_LIB_SYS
45
289M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
289M
        : ERR_PACK(lib, 0, reason);
47
289M
}
Unexecuted instantiation: err_mark.c:err_set_error
Unexecuted instantiation: err_save.c:err_set_error
Unexecuted instantiation: err_prn.c:err_set_error
48
49
static ossl_inline void err_set_debug(ERR_STATE *es, size_t i,
50
                                      const char *file, int line,
51
                                      const char *fn)
52
257M
{
53
    /*
54
     * We dup the file and fn strings because they may be provider owned. If the
55
     * provider gets unloaded, they may not be valid anymore.
56
     */
57
257M
    OPENSSL_free(es->err_file[i]);
58
257M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
257M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
257M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
257M
        strcpy(es->err_file[i], file);
64
65
257M
    es->err_line[i] = line;
66
257M
    OPENSSL_free(es->err_func[i]);
67
257M
    if (fn == NULL || fn[0] == '\0')
68
9.00k
        es->err_func[i] = NULL;
69
257M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
257M
                                              NULL, 0)) != NULL)
71
257M
        strcpy(es->err_func[i], fn);
72
257M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
52
257M
{
53
    /*
54
     * We dup the file and fn strings because they may be provider owned. If the
55
     * provider gets unloaded, they may not be valid anymore.
56
     */
57
257M
    OPENSSL_free(es->err_file[i]);
58
257M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
257M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
257M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
257M
        strcpy(es->err_file[i], file);
64
65
257M
    es->err_line[i] = line;
66
257M
    OPENSSL_free(es->err_func[i]);
67
257M
    if (fn == NULL || fn[0] == '\0')
68
9.00k
        es->err_func[i] = NULL;
69
257M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
257M
                                              NULL, 0)) != NULL)
71
257M
        strcpy(es->err_func[i], fn);
72
257M
}
Unexecuted instantiation: err_mark.c:err_set_debug
err_save.c:err_set_debug
Line
Count
Source
52
61.6k
{
53
    /*
54
     * We dup the file and fn strings because they may be provider owned. If the
55
     * provider gets unloaded, they may not be valid anymore.
56
     */
57
61.6k
    OPENSSL_free(es->err_file[i]);
58
61.6k
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
61.6k
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
61.6k
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
61.6k
        strcpy(es->err_file[i], file);
64
65
61.6k
    es->err_line[i] = line;
66
61.6k
    OPENSSL_free(es->err_func[i]);
67
61.6k
    if (fn == NULL || fn[0] == '\0')
68
0
        es->err_func[i] = NULL;
69
61.6k
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
61.6k
                                              NULL, 0)) != NULL)
71
61.6k
        strcpy(es->err_func[i], fn);
72
61.6k
}
Unexecuted instantiation: err_prn.c:err_set_debug
73
74
static ossl_inline void err_set_data(ERR_STATE *es, size_t i,
75
                                     void *data, size_t datasz, int flags)
76
22.2M
{
77
22.2M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
18.4M
        OPENSSL_free(es->err_data[i]);
79
22.2M
    es->err_data[i] = data;
80
22.2M
    es->err_data_size[i] = datasz;
81
22.2M
    es->err_data_flags[i] = flags;
82
22.2M
}
err.c:err_set_data
Line
Count
Source
76
18.5M
{
77
18.5M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
18.4M
        OPENSSL_free(es->err_data[i]);
79
18.5M
    es->err_data[i] = data;
80
18.5M
    es->err_data_size[i] = datasz;
81
18.5M
    es->err_data_flags[i] = flags;
82
18.5M
}
err_blocks.c:err_set_data
Line
Count
Source
76
3.65M
{
77
3.65M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
0
        OPENSSL_free(es->err_data[i]);
79
3.65M
    es->err_data[i] = data;
80
3.65M
    es->err_data_size[i] = datasz;
81
3.65M
    es->err_data_flags[i] = flags;
82
3.65M
}
Unexecuted instantiation: err_mark.c:err_set_data
err_save.c:err_set_data
Line
Count
Source
76
51.4k
{
77
51.4k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
2.35k
        OPENSSL_free(es->err_data[i]);
79
51.4k
    es->err_data[i] = data;
80
51.4k
    es->err_data_size[i] = datasz;
81
51.4k
    es->err_data_flags[i] = flags;
82
51.4k
}
Unexecuted instantiation: err_prn.c:err_set_data
83
84
static ossl_inline void err_clear(ERR_STATE *es, size_t i, int deall)
85
1.61G
{
86
1.61G
    err_clear_data(es, i, (deall));
87
1.61G
    es->err_marks[i] = 0;
88
1.61G
    es->err_flags[i] = 0;
89
1.61G
    es->err_buffer[i] = 0;
90
1.61G
    es->err_line[i] = -1;
91
1.61G
    OPENSSL_free(es->err_file[i]);
92
1.61G
    es->err_file[i] = NULL;
93
1.61G
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
1.61G
}
err.c:err_clear
Line
Count
Source
85
1.09G
{
86
1.09G
    err_clear_data(es, i, (deall));
87
1.09G
    es->err_marks[i] = 0;
88
1.09G
    es->err_flags[i] = 0;
89
1.09G
    es->err_buffer[i] = 0;
90
1.09G
    es->err_line[i] = -1;
91
1.09G
    OPENSSL_free(es->err_file[i]);
92
1.09G
    es->err_file[i] = NULL;
93
1.09G
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
1.09G
}
err_blocks.c:err_clear
Line
Count
Source
85
289M
{
86
289M
    err_clear_data(es, i, (deall));
87
289M
    es->err_marks[i] = 0;
88
289M
    es->err_flags[i] = 0;
89
289M
    es->err_buffer[i] = 0;
90
289M
    es->err_line[i] = -1;
91
289M
    OPENSSL_free(es->err_file[i]);
92
289M
    es->err_file[i] = NULL;
93
289M
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
289M
}
err_mark.c:err_clear
Line
Count
Source
85
223M
{
86
223M
    err_clear_data(es, i, (deall));
87
223M
    es->err_marks[i] = 0;
88
223M
    es->err_flags[i] = 0;
89
223M
    es->err_buffer[i] = 0;
90
223M
    es->err_line[i] = -1;
91
223M
    OPENSSL_free(es->err_file[i]);
92
223M
    es->err_file[i] = NULL;
93
223M
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
223M
}
err_save.c:err_clear
Line
Count
Source
85
686k
{
86
686k
    err_clear_data(es, i, (deall));
87
686k
    es->err_marks[i] = 0;
88
686k
    es->err_flags[i] = 0;
89
686k
    es->err_buffer[i] = 0;
90
686k
    es->err_line[i] = -1;
91
686k
    OPENSSL_free(es->err_file[i]);
92
686k
    es->err_file[i] = NULL;
93
686k
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
686k
}
Unexecuted instantiation: err_prn.c:err_clear
96
97
ERR_STATE *ossl_err_get_state_int(void);
98
void ossl_err_string_int(unsigned long e, const char *func,
99
                         char *buf, size_t len);