Coverage Report

Created: 2025-11-16 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl32/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
265M
{
16
265M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
265M
    if (es->top == es->bottom)
18
33.3M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
265M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
15
265M
{
16
265M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
265M
    if (es->top == es->bottom)
18
33.2M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
265M
}
err_save.c:err_get_slot
Line
Count
Source
15
57.6k
{
16
57.6k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
57.6k
    if (es->top == es->bottom)
18
7.01k
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
57.6k
}
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.82G
{
23
1.82G
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
854M
        if (deall) {
25
68.7k
            OPENSSL_free(es->err_data[i]);
26
68.7k
            es->err_data[i] = NULL;
27
68.7k
            es->err_data_size[i] = 0;
28
68.7k
            es->err_data_flags[i] = 0;
29
854M
        } else if (es->err_data[i] != NULL) {
30
854M
            es->err_data[i][0] = '\0';
31
854M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
854M
        }
33
969M
    } else {
34
969M
        es->err_data[i] = NULL;
35
969M
        es->err_data_size[i] = 0;
36
969M
        es->err_data_flags[i] = 0;
37
969M
    }
38
1.82G
}
err.c:err_clear_data
Line
Count
Source
22
1.09G
{
23
1.09G
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
127M
        if (deall) {
25
68.7k
            OPENSSL_free(es->err_data[i]);
26
68.7k
            es->err_data[i] = NULL;
27
68.7k
            es->err_data_size[i] = 0;
28
68.7k
            es->err_data_flags[i] = 0;
29
127M
        } else if (es->err_data[i] != NULL) {
30
127M
            es->err_data[i][0] = '\0';
31
127M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
127M
        }
33
963M
    } else {
34
        es->err_data[i] = NULL;
35
963M
        es->err_data_size[i] = 0;
36
963M
        es->err_data_flags[i] = 0;
37
963M
    }
38
1.09G
}
err_blocks.c:err_clear_data
Line
Count
Source
22
530M
{
23
530M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
525M
        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
525M
        } else if (es->err_data[i] != NULL) {
30
525M
            es->err_data[i][0] = '\0';
31
525M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
525M
        }
33
525M
    } else {
34
        es->err_data[i] = NULL;
35
4.78M
        es->err_data_size[i] = 0;
36
4.78M
        es->err_data_flags[i] = 0;
37
4.78M
    }
38
530M
}
err_save.c:err_clear_data
Line
Count
Source
22
634k
{
23
634k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
5.82k
        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.82k
        } else if (es->err_data[i] != NULL) {
30
5.82k
            es->err_data[i][0] = '\0';
31
5.82k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
5.82k
        }
33
628k
    } else {
34
        es->err_data[i] = NULL;
35
628k
        es->err_data_size[i] = 0;
36
628k
        es->err_data_flags[i] = 0;
37
628k
    }
38
634k
}
err_mark.c:err_clear_data
Line
Count
Source
22
202M
{
23
202M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
201M
        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
201M
        } else if (es->err_data[i] != NULL) {
30
201M
            es->err_data[i][0] = '\0';
31
201M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
201M
        }
33
201M
    } else {
34
        es->err_data[i] = NULL;
35
531k
        es->err_data_size[i] = 0;
36
531k
        es->err_data_flags[i] = 0;
37
531k
    }
38
202M
}
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
265M
{
43
265M
    es->err_buffer[i] =
44
265M
        lib == ERR_LIB_SYS
45
265M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
265M
        : ERR_PACK(lib, 0, reason);
47
265M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
42
265M
{
43
265M
    es->err_buffer[i] =
44
265M
        lib == ERR_LIB_SYS
45
265M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
265M
        : ERR_PACK(lib, 0, reason);
47
265M
}
Unexecuted instantiation: err_save.c:err_set_error
Unexecuted instantiation: err_mark.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
232M
{
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
232M
    OPENSSL_free(es->err_file[i]);
58
232M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
232M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
232M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
232M
        strcpy(es->err_file[i], file);
64
65
232M
    es->err_line[i] = line;
66
232M
    OPENSSL_free(es->err_func[i]);
67
232M
    if (fn == NULL || fn[0] == '\0')
68
7.44k
        es->err_func[i] = NULL;
69
232M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
232M
                                              NULL, 0)) != NULL)
71
232M
        strcpy(es->err_func[i], fn);
72
232M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
52
232M
{
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
232M
    OPENSSL_free(es->err_file[i]);
58
232M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
232M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
232M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
232M
        strcpy(es->err_file[i], file);
64
65
232M
    es->err_line[i] = line;
66
232M
    OPENSSL_free(es->err_func[i]);
67
232M
    if (fn == NULL || fn[0] == '\0')
68
7.44k
        es->err_func[i] = NULL;
69
232M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
232M
                                              NULL, 0)) != NULL)
71
232M
        strcpy(es->err_func[i], fn);
72
232M
}
err_save.c:err_set_debug
Line
Count
Source
52
57.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
57.6k
    OPENSSL_free(es->err_file[i]);
58
57.6k
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
57.6k
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
57.6k
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
57.6k
        strcpy(es->err_file[i], file);
64
65
57.6k
    es->err_line[i] = line;
66
57.6k
    OPENSSL_free(es->err_func[i]);
67
57.6k
    if (fn == NULL || fn[0] == '\0')
68
0
        es->err_func[i] = NULL;
69
57.6k
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
57.6k
                                              NULL, 0)) != NULL)
71
57.6k
        strcpy(es->err_func[i], fn);
72
57.6k
}
Unexecuted instantiation: err_mark.c:err_set_debug
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
20.1M
{
77
20.1M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
16.7M
        OPENSSL_free(es->err_data[i]);
79
20.1M
    es->err_data[i] = data;
80
20.1M
    es->err_data_size[i] = datasz;
81
20.1M
    es->err_data_flags[i] = flags;
82
20.1M
}
err.c:err_set_data
Line
Count
Source
76
16.7M
{
77
16.7M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
16.7M
        OPENSSL_free(es->err_data[i]);
79
16.7M
    es->err_data[i] = data;
80
16.7M
    es->err_data_size[i] = datasz;
81
16.7M
    es->err_data_flags[i] = flags;
82
16.7M
}
err_blocks.c:err_set_data
Line
Count
Source
76
3.31M
{
77
3.31M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
0
        OPENSSL_free(es->err_data[i]);
79
3.31M
    es->err_data[i] = data;
80
3.31M
    es->err_data_size[i] = datasz;
81
3.31M
    es->err_data_flags[i] = flags;
82
3.31M
}
err_save.c:err_set_data
Line
Count
Source
76
47.1k
{
77
47.1k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
2.54k
        OPENSSL_free(es->err_data[i]);
79
47.1k
    es->err_data[i] = data;
80
47.1k
    es->err_data_size[i] = datasz;
81
47.1k
    es->err_data_flags[i] = flags;
82
47.1k
}
Unexecuted instantiation: err_mark.c:err_set_data
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.54G
{
86
1.54G
    err_clear_data(es, i, (deall));
87
1.54G
    es->err_marks[i] = 0;
88
1.54G
    es->err_flags[i] = 0;
89
1.54G
    es->err_buffer[i] = 0;
90
1.54G
    es->err_line[i] = -1;
91
1.54G
    OPENSSL_free(es->err_file[i]);
92
1.54G
    es->err_file[i] = NULL;
93
1.54G
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
1.54G
}
err.c:err_clear
Line
Count
Source
85
1.07G
{
86
1.07G
    err_clear_data(es, i, (deall));
87
1.07G
    es->err_marks[i] = 0;
88
1.07G
    es->err_flags[i] = 0;
89
1.07G
    es->err_buffer[i] = 0;
90
1.07G
    es->err_line[i] = -1;
91
1.07G
    OPENSSL_free(es->err_file[i]);
92
1.07G
    es->err_file[i] = NULL;
93
1.07G
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
1.07G
}
err_blocks.c:err_clear
Line
Count
Source
85
265M
{
86
265M
    err_clear_data(es, i, (deall));
87
265M
    es->err_marks[i] = 0;
88
265M
    es->err_flags[i] = 0;
89
265M
    es->err_buffer[i] = 0;
90
265M
    es->err_line[i] = -1;
91
265M
    OPENSSL_free(es->err_file[i]);
92
265M
    es->err_file[i] = NULL;
93
265M
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
265M
}
err_save.c:err_clear
Line
Count
Source
85
623k
{
86
623k
    err_clear_data(es, i, (deall));
87
623k
    es->err_marks[i] = 0;
88
623k
    es->err_flags[i] = 0;
89
623k
    es->err_buffer[i] = 0;
90
623k
    es->err_line[i] = -1;
91
623k
    OPENSSL_free(es->err_file[i]);
92
623k
    es->err_file[i] = NULL;
93
623k
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
623k
}
err_mark.c:err_clear
Line
Count
Source
85
202M
{
86
202M
    err_clear_data(es, i, (deall));
87
202M
    es->err_marks[i] = 0;
88
202M
    es->err_flags[i] = 0;
89
202M
    es->err_buffer[i] = 0;
90
202M
    es->err_line[i] = -1;
91
202M
    OPENSSL_free(es->err_file[i]);
92
202M
    es->err_file[i] = NULL;
93
202M
    OPENSSL_free(es->err_func[i]);
94
    es->err_func[i] = NULL;
95
202M
}
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);