Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl36/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
343M
{
16
343M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
343M
    if (es->top == es->bottom)
18
24.9M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
343M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
15
343M
{
16
343M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
343M
    if (es->top == es->bottom)
18
24.8M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
343M
}
Unexecuted instantiation: err_mark.c:err_get_slot
err_save.c:err_get_slot
Line
Count
Source
15
54.0k
{
16
54.0k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
54.0k
    if (es->top == es->bottom)
18
6.18k
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
54.0k
}
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.78G
{
23
1.78G
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
1.07G
        if (deall) {
25
63.0k
            OPENSSL_free(es->err_data[i]);
26
63.0k
            es->err_data[i] = NULL;
27
63.0k
            es->err_data_size[i] = 0;
28
63.0k
            es->err_data_flags[i] = 0;
29
1.07G
        } else if (es->err_data[i] != NULL) {
30
1.07G
            es->err_data[i][0] = '\0';
31
1.07G
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
1.07G
        }
33
1.07G
    } else {
34
704M
        es->err_data[i] = NULL;
35
704M
        es->err_data_size[i] = 0;
36
704M
        es->err_data_flags[i] = 0;
37
704M
    }
38
1.78G
}
err.c:err_clear_data
Line
Count
Source
22
777M
{
23
777M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
78.7M
        if (deall) {
25
63.0k
            OPENSSL_free(es->err_data[i]);
26
63.0k
            es->err_data[i] = NULL;
27
63.0k
            es->err_data_size[i] = 0;
28
63.0k
            es->err_data_flags[i] = 0;
29
78.6M
        } else if (es->err_data[i] != NULL) {
30
78.6M
            es->err_data[i][0] = '\0';
31
78.6M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
78.6M
        }
33
699M
    } else {
34
        es->err_data[i] = NULL;
35
699M
        es->err_data_size[i] = 0;
36
699M
        es->err_data_flags[i] = 0;
37
699M
    }
38
777M
}
err_blocks.c:err_clear_data
Line
Count
Source
22
687M
{
23
687M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
683M
        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
683M
        } else if (es->err_data[i] != NULL) {
30
683M
            es->err_data[i][0] = '\0';
31
683M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
683M
        }
33
683M
    } else {
34
        es->err_data[i] = NULL;
35
4.49M
        es->err_data_size[i] = 0;
36
4.49M
        es->err_data_flags[i] = 0;
37
4.49M
    }
38
687M
}
err_mark.c:err_clear_data
Line
Count
Source
22
316M
{
23
316M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
315M
        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
315M
        } else if (es->err_data[i] != NULL) {
30
315M
            es->err_data[i][0] = '\0';
31
315M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
315M
        }
33
315M
    } else {
34
        es->err_data[i] = NULL;
35
507k
        es->err_data_size[i] = 0;
36
507k
        es->err_data_flags[i] = 0;
37
507k
    }
38
316M
}
err_save.c:err_clear_data
Line
Count
Source
22
553k
{
23
553k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
6.49k
        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
6.49k
        } else if (es->err_data[i] != NULL) {
30
6.49k
            es->err_data[i][0] = '\0';
31
6.49k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
6.49k
        }
33
546k
    } else {
34
        es->err_data[i] = NULL;
35
546k
        es->err_data_size[i] = 0;
36
546k
        es->err_data_flags[i] = 0;
37
546k
    }
38
553k
}
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
343M
{
43
343M
    es->err_buffer[i] = lib == ERR_LIB_SYS
44
343M
        ? (unsigned int)(ERR_SYSTEM_FLAG | reason)
45
343M
        : ERR_PACK(lib, 0, reason);
46
343M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
42
343M
{
43
343M
    es->err_buffer[i] = lib == ERR_LIB_SYS
44
343M
        ? (unsigned int)(ERR_SYSTEM_FLAG | reason)
45
343M
        : ERR_PACK(lib, 0, reason);
46
343M
}
Unexecuted instantiation: err_mark.c:err_set_error
Unexecuted instantiation: err_save.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
343M
{
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
343M
    OPENSSL_free(es->err_file[i]);
57
343M
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
343M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
60
343M
                  NULL, 0))
61
343M
        != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
343M
        strcpy(es->err_file[i], file);
64
65
343M
    es->err_line[i] = line;
66
343M
    OPENSSL_free(es->err_func[i]);
67
343M
    if (fn == NULL || fn[0] == '\0')
68
7.25k
        es->err_func[i] = NULL;
69
343M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
343M
                  NULL, 0))
71
343M
        != NULL)
72
343M
        strcpy(es->err_func[i], fn);
73
343M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
51
343M
{
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
343M
    OPENSSL_free(es->err_file[i]);
57
343M
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
343M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
60
343M
                  NULL, 0))
61
343M
        != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
343M
        strcpy(es->err_file[i], file);
64
65
343M
    es->err_line[i] = line;
66
343M
    OPENSSL_free(es->err_func[i]);
67
343M
    if (fn == NULL || fn[0] == '\0')
68
7.25k
        es->err_func[i] = NULL;
69
343M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
343M
                  NULL, 0))
71
343M
        != NULL)
72
343M
        strcpy(es->err_func[i], fn);
73
343M
}
Unexecuted instantiation: err_mark.c:err_set_debug
err_save.c:err_set_debug
Line
Count
Source
51
54.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
54.0k
    OPENSSL_free(es->err_file[i]);
57
54.0k
    if (file == NULL || file[0] == '\0')
58
0
        es->err_file[i] = NULL;
59
54.0k
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
60
54.0k
                  NULL, 0))
61
54.0k
        != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
54.0k
        strcpy(es->err_file[i], file);
64
65
54.0k
    es->err_line[i] = line;
66
54.0k
    OPENSSL_free(es->err_func[i]);
67
54.0k
    if (fn == NULL || fn[0] == '\0')
68
0
        es->err_func[i] = NULL;
69
54.0k
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
54.0k
                  NULL, 0))
71
54.0k
        != NULL)
72
54.0k
        strcpy(es->err_func[i], fn);
73
54.0k
}
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
16.0M
{
78
16.0M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
12.8M
        OPENSSL_free(es->err_data[i]);
80
16.0M
    es->err_data[i] = data;
81
16.0M
    es->err_data_size[i] = datasz;
82
16.0M
    es->err_data_flags[i] = flags;
83
16.0M
}
err.c:err_set_data
Line
Count
Source
77
12.9M
{
78
12.9M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
12.8M
        OPENSSL_free(es->err_data[i]);
80
12.9M
    es->err_data[i] = data;
81
12.9M
    es->err_data_size[i] = datasz;
82
12.9M
    es->err_data_flags[i] = flags;
83
12.9M
}
err_blocks.c:err_set_data
Line
Count
Source
77
3.06M
{
78
3.06M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
0
        OPENSSL_free(es->err_data[i]);
80
3.06M
    es->err_data[i] = data;
81
3.06M
    es->err_data_size[i] = datasz;
82
3.06M
    es->err_data_flags[i] = flags;
83
3.06M
}
Unexecuted instantiation: err_mark.c:err_set_data
err_save.c:err_set_data
Line
Count
Source
77
45.0k
{
78
45.0k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
79
2.70k
        OPENSSL_free(es->err_data[i]);
80
45.0k
    es->err_data[i] = data;
81
45.0k
    es->err_data_size[i] = datasz;
82
45.0k
    es->err_data_flags[i] = flags;
83
45.0k
}
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.42G
{
87
1.42G
    err_clear_data(es, i, (deall));
88
1.42G
    es->err_marks[i] = 0;
89
1.42G
    es->err_flags[i] = 0;
90
1.42G
    es->err_buffer[i] = 0;
91
1.42G
    es->err_line[i] = -1;
92
1.42G
    OPENSSL_free(es->err_file[i]);
93
1.42G
    es->err_file[i] = NULL;
94
1.42G
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
1.42G
}
err.c:err_clear
Line
Count
Source
86
765M
{
87
765M
    err_clear_data(es, i, (deall));
88
765M
    es->err_marks[i] = 0;
89
765M
    es->err_flags[i] = 0;
90
765M
    es->err_buffer[i] = 0;
91
765M
    es->err_line[i] = -1;
92
765M
    OPENSSL_free(es->err_file[i]);
93
765M
    es->err_file[i] = NULL;
94
765M
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
765M
}
err_blocks.c:err_clear
Line
Count
Source
86
343M
{
87
343M
    err_clear_data(es, i, (deall));
88
343M
    es->err_marks[i] = 0;
89
343M
    es->err_flags[i] = 0;
90
343M
    es->err_buffer[i] = 0;
91
343M
    es->err_line[i] = -1;
92
343M
    OPENSSL_free(es->err_file[i]);
93
343M
    es->err_file[i] = NULL;
94
343M
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
343M
}
err_mark.c:err_clear
Line
Count
Source
86
316M
{
87
316M
    err_clear_data(es, i, (deall));
88
316M
    es->err_marks[i] = 0;
89
316M
    es->err_flags[i] = 0;
90
316M
    es->err_buffer[i] = 0;
91
316M
    es->err_line[i] = -1;
92
316M
    OPENSSL_free(es->err_file[i]);
93
316M
    es->err_file[i] = NULL;
94
316M
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
316M
}
err_save.c:err_clear
Line
Count
Source
86
544k
{
87
544k
    err_clear_data(es, i, (deall));
88
544k
    es->err_marks[i] = 0;
89
544k
    es->err_flags[i] = 0;
90
544k
    es->err_buffer[i] = 0;
91
544k
    es->err_line[i] = -1;
92
544k
    OPENSSL_free(es->err_file[i]);
93
544k
    es->err_file[i] = NULL;
94
544k
    OPENSSL_free(es->err_func[i]);
95
    es->err_func[i] = NULL;
96
544k
}
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);