Coverage Report

Created: 2026-04-01 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl34/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
284M
{
16
284M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
284M
    if (es->top == es->bottom)
18
33.8M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
284M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
15
284M
{
16
284M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
284M
    if (es->top == es->bottom)
18
33.8M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
284M
}
err_save.c:err_get_slot
Line
Count
Source
15
60.0k
{
16
60.0k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
60.0k
    if (es->top == es->bottom)
18
6.39k
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
60.0k
}
Unexecuted instantiation: err_mark.c:err_get_slot
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
914M
        if (deall) {
25
72.1k
            OPENSSL_free(es->err_data[i]);
26
72.1k
            es->err_data[i] = NULL;
27
72.1k
            es->err_data_size[i] = 0;
28
72.1k
            es->err_data_flags[i] = 0;
29
914M
        } else if (es->err_data[i] != NULL) {
30
914M
            es->err_data[i][0] = '\0';
31
914M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
914M
        }
33
997M
    } else {
34
997M
        es->err_data[i] = NULL;
35
997M
        es->err_data_size[i] = 0;
36
997M
        es->err_data_flags[i] = 0;
37
997M
    }
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
122M
        if (deall) {
25
72.1k
            OPENSSL_free(es->err_data[i]);
26
72.1k
            es->err_data[i] = NULL;
27
72.1k
            es->err_data_size[i] = 0;
28
72.1k
            es->err_data_flags[i] = 0;
29
122M
        } else if (es->err_data[i] != NULL) {
30
122M
            es->err_data[i][0] = '\0';
31
122M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
122M
        }
33
990M
    } else {
34
        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.11G
}
err_blocks.c:err_clear_data
Line
Count
Source
22
569M
{
23
569M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
563M
        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
563M
        } else if (es->err_data[i] != NULL) {
30
563M
            es->err_data[i][0] = '\0';
31
563M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
563M
        }
33
563M
    } else {
34
        es->err_data[i] = NULL;
35
5.79M
        es->err_data_size[i] = 0;
36
5.79M
        es->err_data_flags[i] = 0;
37
5.79M
    }
38
569M
}
err_save.c:err_clear_data
Line
Count
Source
22
651k
{
23
651k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
5.95k
        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
5.95k
        } else if (es->err_data[i] != NULL) {
30
5.95k
            es->err_data[i][0] = '\0';
31
5.95k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
5.95k
        }
33
645k
    } else {
34
        es->err_data[i] = NULL;
35
645k
        es->err_data_size[i] = 0;
36
645k
        es->err_data_flags[i] = 0;
37
645k
    }
38
651k
}
err_mark.c:err_clear_data
Line
Count
Source
22
229M
{
23
229M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
228M
        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
228M
        } else if (es->err_data[i] != NULL) {
30
228M
            es->err_data[i][0] = '\0';
31
228M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
228M
        }
33
228M
    } else {
34
        es->err_data[i] = NULL;
35
723k
        es->err_data_size[i] = 0;
36
723k
        es->err_data_flags[i] = 0;
37
723k
    }
38
229M
}
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
284M
{
43
284M
    es->err_buffer[i] = lib == ERR_LIB_SYS
44
284M
        ? (unsigned int)(ERR_SYSTEM_FLAG | reason)
45
284M
        : ERR_PACK(lib, 0, reason);
46
284M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
42
284M
{
43
284M
    es->err_buffer[i] = lib == ERR_LIB_SYS
44
284M
        ? (unsigned int)(ERR_SYSTEM_FLAG | reason)
45
284M
        : ERR_PACK(lib, 0, reason);
46
284M
}
Unexecuted instantiation: err_save.c:err_set_error
Unexecuted instantiation: err_mark.c:err_set_error
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
260M
{
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
260M
    OPENSSL_free(es->err_file[i]);
57
260M
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
260M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
60
260M
                  NULL, 0))
61
260M
        != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
260M
        strcpy(es->err_file[i], file);
64
65
260M
    es->err_line[i] = line;
66
260M
    OPENSSL_free(es->err_func[i]);
67
260M
    if (fn == NULL || fn[0] == '\0')
68
7.67k
        es->err_func[i] = NULL;
69
260M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
260M
                  NULL, 0))
71
260M
        != NULL)
72
260M
        strcpy(es->err_func[i], fn);
73
260M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
51
260M
{
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
260M
    OPENSSL_free(es->err_file[i]);
57
260M
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
260M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
60
260M
                  NULL, 0))
61
260M
        != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
260M
        strcpy(es->err_file[i], file);
64
65
260M
    es->err_line[i] = line;
66
260M
    OPENSSL_free(es->err_func[i]);
67
260M
    if (fn == NULL || fn[0] == '\0')
68
7.67k
        es->err_func[i] = NULL;
69
260M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
260M
                  NULL, 0))
71
260M
        != NULL)
72
260M
        strcpy(es->err_func[i], fn);
73
260M
}
err_save.c:err_set_debug
Line
Count
Source
51
60.0k
{
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
60.0k
    OPENSSL_free(es->err_file[i]);
57
60.0k
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
60.0k
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
60
60.0k
                  NULL, 0))
61
60.0k
        != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
60.0k
        strcpy(es->err_file[i], file);
64
65
60.0k
    es->err_line[i] = line;
66
60.0k
    OPENSSL_free(es->err_func[i]);
67
60.0k
    if (fn == NULL || fn[0] == '\0')
68
0
        es->err_func[i] = NULL;
69
60.0k
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
60.0k
                  NULL, 0))
71
60.0k
        != NULL)
72
60.0k
        strcpy(es->err_func[i], fn);
73
60.0k
}
Unexecuted instantiation: err_mark.c:err_set_debug
Unexecuted instantiation: err_prn.c:err_set_debug
74
75
static ossl_inline void err_set_data(ERR_STATE *es, size_t i,
76
    void *data, size_t datasz, int flags)
77
21.0M
{
78
21.0M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
17.2M
        OPENSSL_free(es->err_data[i]);
80
21.0M
    es->err_data[i] = data;
81
21.0M
    es->err_data_size[i] = datasz;
82
21.0M
    es->err_data_flags[i] = flags;
83
21.0M
}
err.c:err_set_data
Line
Count
Source
77
17.2M
{
78
17.2M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
17.2M
        OPENSSL_free(es->err_data[i]);
80
17.2M
    es->err_data[i] = data;
81
17.2M
    es->err_data_size[i] = datasz;
82
17.2M
    es->err_data_flags[i] = flags;
83
17.2M
}
err_blocks.c:err_set_data
Line
Count
Source
77
3.73M
{
78
3.73M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
0
        OPENSSL_free(es->err_data[i]);
80
3.73M
    es->err_data[i] = data;
81
3.73M
    es->err_data_size[i] = datasz;
82
3.73M
    es->err_data_flags[i] = flags;
83
3.73M
}
err_save.c:err_set_data
Line
Count
Source
77
50.2k
{
78
50.2k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
3.10k
        OPENSSL_free(es->err_data[i]);
80
50.2k
    es->err_data[i] = data;
81
50.2k
    es->err_data_size[i] = datasz;
82
50.2k
    es->err_data_flags[i] = flags;
83
50.2k
}
Unexecuted instantiation: err_mark.c:err_set_data
Unexecuted instantiation: err_prn.c:err_set_data
84
85
static ossl_inline void err_clear(ERR_STATE *es, size_t i, int deall)
86
1.61G
{
87
1.61G
    err_clear_data(es, i, (deall));
88
1.61G
    es->err_marks[i] = 0;
89
1.61G
    es->err_flags[i] = 0;
90
1.61G
    es->err_buffer[i] = 0;
91
1.61G
    es->err_line[i] = -1;
92
1.61G
    OPENSSL_free(es->err_file[i]);
93
1.61G
    es->err_file[i] = NULL;
94
1.61G
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
1.61G
}
err.c:err_clear
Line
Count
Source
86
1.09G
{
87
1.09G
    err_clear_data(es, i, (deall));
88
1.09G
    es->err_marks[i] = 0;
89
1.09G
    es->err_flags[i] = 0;
90
1.09G
    es->err_buffer[i] = 0;
91
1.09G
    es->err_line[i] = -1;
92
1.09G
    OPENSSL_free(es->err_file[i]);
93
1.09G
    es->err_file[i] = NULL;
94
1.09G
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
1.09G
}
err_blocks.c:err_clear
Line
Count
Source
86
284M
{
87
284M
    err_clear_data(es, i, (deall));
88
284M
    es->err_marks[i] = 0;
89
284M
    es->err_flags[i] = 0;
90
284M
    es->err_buffer[i] = 0;
91
284M
    es->err_line[i] = -1;
92
284M
    OPENSSL_free(es->err_file[i]);
93
284M
    es->err_file[i] = NULL;
94
284M
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
284M
}
err_save.c:err_clear
Line
Count
Source
86
641k
{
87
641k
    err_clear_data(es, i, (deall));
88
641k
    es->err_marks[i] = 0;
89
641k
    es->err_flags[i] = 0;
90
641k
    es->err_buffer[i] = 0;
91
641k
    es->err_line[i] = -1;
92
641k
    OPENSSL_free(es->err_file[i]);
93
641k
    es->err_file[i] = NULL;
94
641k
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
641k
}
err_mark.c:err_clear
Line
Count
Source
86
229M
{
87
229M
    err_clear_data(es, i, (deall));
88
229M
    es->err_marks[i] = 0;
89
229M
    es->err_flags[i] = 0;
90
229M
    es->err_buffer[i] = 0;
91
229M
    es->err_line[i] = -1;
92
229M
    OPENSSL_free(es->err_file[i]);
93
229M
    es->err_file[i] = NULL;
94
229M
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
229M
}
Unexecuted instantiation: err_prn.c:err_clear
97
98
ERR_STATE *ossl_err_get_state_int(void);
99
void ossl_err_string_int(unsigned long e, const char *func,
100
    char *buf, size_t len);