Coverage Report

Created: 2024-07-27 06:39

/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
115M
{
16
115M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
115M
    if (es->top == es->bottom)
18
21.6M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
115M
}
Unexecuted instantiation: err.c:err_get_slot
err_blocks.c:err_get_slot
Line
Count
Source
15
115M
{
16
115M
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
115M
    if (es->top == es->bottom)
18
21.6M
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
115M
}
Unexecuted instantiation: err_mark.c:err_get_slot
Unexecuted instantiation: err_prn.c:err_get_slot
err_save.c:err_get_slot
Line
Count
Source
15
25.1k
{
16
25.1k
    es->top = (es->top + 1) % ERR_NUM_ERRORS;
17
25.1k
    if (es->top == es->bottom)
18
3.19k
        es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
19
25.1k
}
20
21
static ossl_inline void err_clear_data(ERR_STATE *es, size_t i, int deall)
22
762M
{
23
762M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
368M
        if (deall) {
25
29.6k
            OPENSSL_free(es->err_data[i]);
26
29.6k
            es->err_data[i] = NULL;
27
29.6k
            es->err_data_size[i] = 0;
28
29.6k
            es->err_data_flags[i] = 0;
29
368M
        } else if (es->err_data[i] != NULL) {
30
368M
            es->err_data[i][0] = '\0';
31
368M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
368M
        }
33
393M
    } else {
34
393M
        es->err_data[i] = NULL;
35
393M
        es->err_data_size[i] = 0;
36
393M
        es->err_data_flags[i] = 0;
37
393M
    }
38
762M
}
err.c:err_clear_data
Line
Count
Source
22
471M
{
23
471M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
80.8M
        if (deall) {
25
29.6k
            OPENSSL_free(es->err_data[i]);
26
29.6k
            es->err_data[i] = NULL;
27
29.6k
            es->err_data_size[i] = 0;
28
29.6k
            es->err_data_flags[i] = 0;
29
80.8M
        } else if (es->err_data[i] != NULL) {
30
80.8M
            es->err_data[i][0] = '\0';
31
80.8M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
80.8M
        }
33
390M
    } else {
34
390M
        es->err_data[i] = NULL;
35
390M
        es->err_data_size[i] = 0;
36
390M
        es->err_data_flags[i] = 0;
37
390M
    }
38
471M
}
err_blocks.c:err_clear_data
Line
Count
Source
22
231M
{
23
231M
    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
2.64M
        es->err_data[i] = NULL;
35
2.64M
        es->err_data_size[i] = 0;
36
2.64M
        es->err_data_flags[i] = 0;
37
2.64M
    }
38
231M
}
err_mark.c:err_clear_data
Line
Count
Source
22
59.6M
{
23
59.6M
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
59.3M
        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
59.3M
        } else if (es->err_data[i] != NULL) {
30
59.3M
            es->err_data[i][0] = '\0';
31
59.3M
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
59.3M
        }
33
59.3M
    } else {
34
333k
        es->err_data[i] = NULL;
35
333k
        es->err_data_size[i] = 0;
36
333k
        es->err_data_flags[i] = 0;
37
333k
    }
38
59.6M
}
Unexecuted instantiation: err_prn.c:err_clear_data
err_save.c:err_clear_data
Line
Count
Source
22
282k
{
23
282k
    if (es->err_data_flags[i] & ERR_TXT_MALLOCED) {
24
3.34k
        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
3.34k
        } else if (es->err_data[i] != NULL) {
30
3.34k
            es->err_data[i][0] = '\0';
31
3.34k
            es->err_data_flags[i] = ERR_TXT_MALLOCED;
32
3.34k
        }
33
278k
    } else {
34
278k
        es->err_data[i] = NULL;
35
278k
        es->err_data_size[i] = 0;
36
278k
        es->err_data_flags[i] = 0;
37
278k
    }
38
282k
}
39
40
static ossl_inline void err_set_error(ERR_STATE *es, size_t i,
41
                                      int lib, int reason)
42
115M
{
43
115M
    es->err_buffer[i] =
44
115M
        lib == ERR_LIB_SYS
45
115M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
115M
        : ERR_PACK(lib, 0, reason);
47
115M
}
Unexecuted instantiation: err.c:err_set_error
err_blocks.c:err_set_error
Line
Count
Source
42
115M
{
43
115M
    es->err_buffer[i] =
44
115M
        lib == ERR_LIB_SYS
45
115M
        ? (unsigned int)(ERR_SYSTEM_FLAG |  reason)
46
115M
        : ERR_PACK(lib, 0, reason);
47
115M
}
Unexecuted instantiation: err_mark.c:err_set_error
Unexecuted instantiation: err_prn.c:err_set_error
Unexecuted instantiation: err_save.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
71.5M
{
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
71.5M
    OPENSSL_free(es->err_file[i]);
58
71.5M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
71.5M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
71.5M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
71.5M
        strcpy(es->err_file[i], file);
64
65
71.5M
    es->err_line[i] = line;
66
71.5M
    OPENSSL_free(es->err_func[i]);
67
71.5M
    if (fn == NULL || fn[0] == '\0')
68
2.82k
        es->err_func[i] = NULL;
69
71.5M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
71.5M
                                              NULL, 0)) != NULL)
71
71.5M
        strcpy(es->err_func[i], fn);
72
71.5M
}
Unexecuted instantiation: err.c:err_set_debug
err_blocks.c:err_set_debug
Line
Count
Source
52
71.5M
{
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
71.5M
    OPENSSL_free(es->err_file[i]);
58
71.5M
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
71.5M
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
71.5M
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
71.5M
        strcpy(es->err_file[i], file);
64
65
71.5M
    es->err_line[i] = line;
66
71.5M
    OPENSSL_free(es->err_func[i]);
67
71.5M
    if (fn == NULL || fn[0] == '\0')
68
2.82k
        es->err_func[i] = NULL;
69
71.5M
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
71.5M
                                              NULL, 0)) != NULL)
71
71.5M
        strcpy(es->err_func[i], fn);
72
71.5M
}
Unexecuted instantiation: err_mark.c:err_set_debug
Unexecuted instantiation: err_prn.c:err_set_debug
err_save.c:err_set_debug
Line
Count
Source
52
25.1k
{
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.1k
    OPENSSL_free(es->err_file[i]);
58
25.1k
    if (file == NULL || file[0] == '\0')
59
0
        es->err_file[i] = NULL;
60
25.1k
    else if ((es->err_file[i] = CRYPTO_malloc(strlen(file) + 1,
61
25.1k
                                              NULL, 0)) != NULL)
62
        /* We cannot use OPENSSL_strdup due to possible recursion */
63
25.1k
        strcpy(es->err_file[i], file);
64
65
25.1k
    es->err_line[i] = line;
66
25.1k
    OPENSSL_free(es->err_func[i]);
67
25.1k
    if (fn == NULL || fn[0] == '\0')
68
0
        es->err_func[i] = NULL;
69
25.1k
    else if ((es->err_func[i] = CRYPTO_malloc(strlen(fn) + 1,
70
25.1k
                                              NULL, 0)) != NULL)
71
25.1k
        strcpy(es->err_func[i], fn);
72
25.1k
}
73
74
static ossl_inline void err_set_data(ERR_STATE *es, size_t i,
75
                                     void *data, size_t datasz, int flags)
76
12.2M
{
77
12.2M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
10.4M
        OPENSSL_free(es->err_data[i]);
79
12.2M
    es->err_data[i] = data;
80
12.2M
    es->err_data_size[i] = datasz;
81
12.2M
    es->err_data_flags[i] = flags;
82
12.2M
}
err.c:err_set_data
Line
Count
Source
76
10.4M
{
77
10.4M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
10.4M
        OPENSSL_free(es->err_data[i]);
79
10.4M
    es->err_data[i] = data;
80
10.4M
    es->err_data_size[i] = datasz;
81
10.4M
    es->err_data_flags[i] = flags;
82
10.4M
}
err_blocks.c:err_set_data
Line
Count
Source
76
1.75M
{
77
1.75M
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
0
        OPENSSL_free(es->err_data[i]);
79
1.75M
    es->err_data[i] = data;
80
1.75M
    es->err_data_size[i] = datasz;
81
1.75M
    es->err_data_flags[i] = flags;
82
1.75M
}
Unexecuted instantiation: err_mark.c:err_set_data
Unexecuted instantiation: err_prn.c:err_set_data
err_save.c:err_set_data
Line
Count
Source
76
20.4k
{
77
20.4k
    if ((es->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
78
1.30k
        OPENSSL_free(es->err_data[i]);
79
20.4k
    es->err_data[i] = data;
80
20.4k
    es->err_data_size[i] = datasz;
81
20.4k
    es->err_data_flags[i] = flags;
82
20.4k
}
83
84
static ossl_inline void err_clear(ERR_STATE *es, size_t i, int deall)
85
636M
{
86
636M
    err_clear_data(es, i, (deall));
87
636M
    es->err_marks[i] = 0;
88
636M
    es->err_flags[i] = 0;
89
636M
    es->err_buffer[i] = 0;
90
636M
    es->err_line[i] = -1;
91
636M
    OPENSSL_free(es->err_file[i]);
92
636M
    es->err_file[i] = NULL;
93
636M
    OPENSSL_free(es->err_func[i]);
94
636M
    es->err_func[i] = NULL;
95
636M
}
err.c:err_clear
Line
Count
Source
85
460M
{
86
460M
    err_clear_data(es, i, (deall));
87
460M
    es->err_marks[i] = 0;
88
460M
    es->err_flags[i] = 0;
89
460M
    es->err_buffer[i] = 0;
90
460M
    es->err_line[i] = -1;
91
460M
    OPENSSL_free(es->err_file[i]);
92
460M
    es->err_file[i] = NULL;
93
460M
    OPENSSL_free(es->err_func[i]);
94
460M
    es->err_func[i] = NULL;
95
460M
}
err_blocks.c:err_clear
Line
Count
Source
85
115M
{
86
115M
    err_clear_data(es, i, (deall));
87
115M
    es->err_marks[i] = 0;
88
115M
    es->err_flags[i] = 0;
89
115M
    es->err_buffer[i] = 0;
90
115M
    es->err_line[i] = -1;
91
115M
    OPENSSL_free(es->err_file[i]);
92
115M
    es->err_file[i] = NULL;
93
115M
    OPENSSL_free(es->err_func[i]);
94
115M
    es->err_func[i] = NULL;
95
115M
}
err_mark.c:err_clear
Line
Count
Source
85
59.6M
{
86
59.6M
    err_clear_data(es, i, (deall));
87
59.6M
    es->err_marks[i] = 0;
88
59.6M
    es->err_flags[i] = 0;
89
59.6M
    es->err_buffer[i] = 0;
90
59.6M
    es->err_line[i] = -1;
91
59.6M
    OPENSSL_free(es->err_file[i]);
92
59.6M
    es->err_file[i] = NULL;
93
59.6M
    OPENSSL_free(es->err_func[i]);
94
59.6M
    es->err_func[i] = NULL;
95
59.6M
}
Unexecuted instantiation: err_prn.c:err_clear
err_save.c:err_clear
Line
Count
Source
85
277k
{
86
277k
    err_clear_data(es, i, (deall));
87
277k
    es->err_marks[i] = 0;
88
277k
    es->err_flags[i] = 0;
89
277k
    es->err_buffer[i] = 0;
90
277k
    es->err_line[i] = -1;
91
277k
    OPENSSL_free(es->err_file[i]);
92
277k
    es->err_file[i] = NULL;
93
277k
    OPENSSL_free(es->err_func[i]);
94
277k
    es->err_func[i] = NULL;
95
277k
}
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);