Coverage Report

Created: 2025-06-13 06:58

/src/openssl32/crypto/err/err_local.h
Line
Count
Source (jump to first uncovered line)
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
140M
{
16
140M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
140M
    if (es->top == es->bottom)
18
23.4M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
140M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
15
140M
{
16
140M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
140M
    if (es->top == es->bottom)
18
23.4M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
140M
}
err_save.c:err_get_slot
Line
Count
Source
15
25.6k
{
16
25.6k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
25.6k
    if (es->top == es->bottom)
18
2.80k
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
25.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
857M
{
23
857M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
448M
        if (deall) {
25
33.1k
            OPENSSL_free(es->err_data[i]);
26
33.1k
            es->err_data[i] = NULL;
27
33.1k
            es->err_data_size[i] = 0;
28
33.1k
            es->err_data_flags[i] = 0;
29
448M
        } else if (es->err_data[i] != NULL) {
30
448M
            es->err_data[i][0] = '\0';
31
448M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
448M
        }
33
448M
    } else {
34
409M
        es->err_data[i] = NULL;
35
409M
        es->err_data_size[i] = 0;
36
409M
        es->err_data_flags[i] = 0;
37
409M
    }
38
857M
}
err.c:err_clear_data
Line
Count
Source
22
495M
{
23
495M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
89.4M
        if (deall) {
25
33.1k
            OPENSSL_free(es->err_data[i]);
26
33.1k
            es->err_data[i] = NULL;
27
33.1k
            es->err_data_size[i] = 0;
28
33.1k
            es->err_data_flags[i] = 0;
29
89.3M
        } else if (es->err_data[i] != NULL) {
30
89.3M
            es->err_data[i][0] = '\0';
31
89.3M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
89.3M
        }
33
405M
    } else {
34
405M
        es->err_data[i] = NULL;
35
405M
        es->err_data_size[i] = 0;
36
405M
        es->err_data_flags[i] = 0;
37
405M
    }
38
495M
}
err_blocks.c:err_clear_data
Line
Count
Source
22
280M
{
23
280M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
277M
        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
277M
        } else if (es->err_data[i] != NULL) {
30
277M
            es->err_data[i][0] = '\0';
31
277M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
277M
        }
33
277M
    } else {
34
2.86M
        es->err_data[i] = NULL;
35
2.86M
        es->err_data_size[i] = 0;
36
2.86M
        es->err_data_flags[i] = 0;
37
2.86M
    }
38
280M
}
err_save.c:err_clear_data
Line
Count
Source
22
282k
{
23
282k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
2.65k
        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
2.65k
        } else if (es->err_data[i] != NULL) {
30
2.65k
            es->err_data[i][0] = '\0';
31
2.65k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
2.65k
        }
33
280k
    } else {
34
280k
        es->err_data[i] = NULL;
35
280k
        es->err_data_size[i] = 0;
36
280k
        es->err_data_flags[i] = 0;
37
280k
    }
38
282k
}
err_mark.c:err_clear_data
Line
Count
Source
22
82.4M
{
23
82.4M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
82.0M
        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
82.0M
        } else if (es->err_data[i] != NULL) {
30
82.0M
            es->err_data[i][0] = '\0';
31
82.0M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
82.0M
        }
33
82.0M
    } else {
34
349k
        es->err_data[i] = NULL;
35
349k
        es->err_data_size[i] = 0;
36
349k
        es->err_data_flags[i] = 0;
37
349k
    }
38
82.4M
}
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
140M
{
43
140M
    es->err_buffer[i] =
44
140M
        lib == ERR_LIB_SYS
45
140M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
140M
        : ERR_PACK(lib, 0, reason);
47
140M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
42
140M
{
43
140M
    es->err_buffer[i] =
44
140M
        lib == ERR_LIB_SYS
45
140M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
140M
        : ERR_PACK(lib, 0, reason);
47
140M
}
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
95.0M
{
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
95.0M
    OPENSSL_free(es->err_file[i]);
58
95.0M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
95.0M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
95.0M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
95.0M
        strcpy(es->err_file[i], file);
64
65
95.0M
    es->err_line[i] = line;
66
95.0M
    OPENSSL_free(es->err_func[i]);
67
95.0M
    if (fn == NULL || fn[0] == '\0')
68
2.86k
        es->err_func[i] = NULL;
69
95.0M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
95.0M
                                              NULL, 0)) != NULL)
71
95.0M
        strcpy(es->err_func[i], fn);
72
95.0M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
52
95.0M
{
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
95.0M
    OPENSSL_free(es->err_file[i]);
58
95.0M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
95.0M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
95.0M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
95.0M
        strcpy(es->err_file[i], file);
64
65
95.0M
    es->err_line[i] = line;
66
95.0M
    OPENSSL_free(es->err_func[i]);
67
95.0M
    if (fn == NULL || fn[0] == '\0')
68
2.86k
        es->err_func[i] = NULL;
69
95.0M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
95.0M
                                              NULL, 0)) != NULL)
71
95.0M
        strcpy(es->err_func[i], fn);
72
95.0M
}
err_save.c:err_set_debug
Line
Count
Source
52
25.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
25.6k
    OPENSSL_free(es->err_file[i]);
58
25.6k
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
25.6k
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
25.6k
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
25.6k
        strcpy(es->err_file[i], file);
64
65
25.6k
    es->err_line[i] = line;
66
25.6k
    OPENSSL_free(es->err_func[i]);
67
25.6k
    if (fn == NULL || fn[0] == '\0')
68
0
        es->err_func[i] = NULL;
69
25.6k
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
25.6k
                                              NULL, 0)) != NULL)
71
25.6k
        strcpy(es->err_func[i], fn);
72
25.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
13.6M
{
77
13.6M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
11.6M
        OPENSSL_free(es->err_data[i]);
79
13.6M
    es->err_data[i] = data;
80
13.6M
    es->err_data_size[i] = datasz;
81
13.6M
    es->err_data_flags[i] = flags;
82
13.6M
}
err.c:err_set_data
Line
Count
Source
76
11.6M
{
77
11.6M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
11.6M
        OPENSSL_free(es->err_data[i]);
79
11.6M
    es->err_data[i] = data;
80
11.6M
    es->err_data_size[i] = datasz;
81
11.6M
    es->err_data_flags[i] = flags;
82
11.6M
}
err_blocks.c:err_set_data
Line
Count
Source
76
1.94M
{
77
1.94M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
0
        OPENSSL_free(es->err_data[i]);
79
1.94M
    es->err_data[i] = data;
80
1.94M
    es->err_data_size[i] = datasz;
81
1.94M
    es->err_data_flags[i] = flags;
82
1.94M
}
err_save.c:err_set_data
Line
Count
Source
76
21.9k
{
77
21.9k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
1.29k
        OPENSSL_free(es->err_data[i]);
79
21.9k
    es->err_data[i] = data;
80
21.9k
    es->err_data_size[i] = datasz;
81
21.9k
    es->err_data_flags[i] = flags;
82
21.9k
}
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
706M
{
86
706M
    err_clear_data(es, i, (deall));
87
706M
    es->err_marks[i] = 0;
88
706M
    es->err_flags[i] = 0;
89
706M
    es->err_buffer[i] = 0;
90
706M
    es->err_line[i] = -1;
91
706M
    OPENSSL_free(es->err_file[i]);
92
706M
    es->err_file[i] = NULL;
93
706M
    OPENSSL_free(es->err_func[i]);
94
706M
    es->err_func[i] = NULL;
95
706M
}
err.c:err_clear
Line
Count
Source
85
483M
{
86
483M
    err_clear_data(es, i, (deall));
87
483M
    es->err_marks[i] = 0;
88
483M
    es->err_flags[i] = 0;
89
483M
    es->err_buffer[i] = 0;
90
483M
    es->err_line[i] = -1;
91
483M
    OPENSSL_free(es->err_file[i]);
92
483M
    es->err_file[i] = NULL;
93
483M
    OPENSSL_free(es->err_func[i]);
94
483M
    es->err_func[i] = NULL;
95
483M
}
err_blocks.c:err_clear
Line
Count
Source
85
140M
{
86
140M
    err_clear_data(es, i, (deall));
87
140M
    es->err_marks[i] = 0;
88
140M
    es->err_flags[i] = 0;
89
140M
    es->err_buffer[i] = 0;
90
140M
    es->err_line[i] = -1;
91
140M
    OPENSSL_free(es->err_file[i]);
92
140M
    es->err_file[i] = NULL;
93
140M
    OPENSSL_free(es->err_func[i]);
94
140M
    es->err_func[i] = NULL;
95
140M
}
err_save.c:err_clear
Line
Count
Source
85
279k
{
86
279k
    err_clear_data(es, i, (deall));
87
279k
    es->err_marks[i] = 0;
88
279k
    es->err_flags[i] = 0;
89
279k
    es->err_buffer[i] = 0;
90
279k
    es->err_line[i] = -1;
91
279k
    OPENSSL_free(es->err_file[i]);
92
279k
    es->err_file[i] = NULL;
93
279k
    OPENSSL_free(es->err_func[i]);
94
279k
    es->err_func[i] = NULL;
95
279k
}
err_mark.c:err_clear
Line
Count
Source
85
82.4M
{
86
82.4M
    err_clear_data(es, i, (deall));
87
82.4M
    es->err_marks[i] = 0;
88
82.4M
    es->err_flags[i] = 0;
89
82.4M
    es->err_buffer[i] = 0;
90
82.4M
    es->err_line[i] = -1;
91
82.4M
    OPENSSL_free(es->err_file[i]);
92
82.4M
    es->err_file[i] = NULL;
93
82.4M
    OPENSSL_free(es->err_func[i]);
94
82.4M
    es->err_func[i] = NULL;
95
82.4M
}
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);