Coverage Report

Created: 2024-07-27 06:39

/src/openssl32/crypto/err/err_mark.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2003-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
#define OSSL_FORCE_ERR_STATE
11
12
#include <openssl/err.h>
13
#include "err_local.h"
14
15
int ERR_set_mark(void)
16
76.4M
{
17
76.4M
    ERR_STATE *es;
18
19
76.4M
    es = ossl_err_get_state_int();
20
76.4M
    if (es == NULL)
21
0
        return 0;
22
23
76.4M
    if (es->bottom == es->top)
24
72.1M
        return 0;
25
4.32M
    es->err_marks[es->top]++;
26
4.32M
    return 1;
27
76.4M
}
28
29
int ERR_pop_to_mark(void)
30
125M
{
31
125M
    ERR_STATE *es;
32
33
125M
    es = ossl_err_get_state_int();
34
125M
    if (es == NULL)
35
0
        return 0;
36
37
217M
    while (es->bottom != es->top
38
217M
           && es->err_marks[es->top] == 0) {
39
92.3M
        err_clear(es, es->top, 0);
40
92.3M
        es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
41
92.3M
    }
42
43
125M
    if (es->bottom == es->top)
44
122M
        return 0;
45
2.98M
    es->err_marks[es->top]--;
46
2.98M
    return 1;
47
125M
}
48
49
int ERR_count_to_mark(void)
50
27.1M
{
51
27.1M
    ERR_STATE *es;
52
27.1M
    int count = 0, top;
53
54
27.1M
    es = ossl_err_get_state_int();
55
27.1M
    if (es == NULL)
56
0
        return 0;
57
58
27.1M
    top = es->top;
59
27.1M
    while (es->bottom != top
60
27.1M
           && es->err_marks[top] == 0) {
61
1.75k
        ++count;
62
1.75k
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
63
1.75k
    }
64
65
27.1M
    return count;
66
27.1M
}
67
68
int ERR_clear_last_mark(void)
69
7.44M
{
70
7.44M
    ERR_STATE *es;
71
7.44M
    int top;
72
73
7.44M
    es = ossl_err_get_state_int();
74
7.44M
    if (es == NULL)
75
0
        return 0;
76
77
7.44M
    top = es->top;
78
11.3M
    while (es->bottom != top
79
11.3M
           && es->err_marks[top] == 0) {
80
3.87M
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
81
3.87M
    }
82
83
7.44M
    if (es->bottom == top)
84
6.43M
        return 0;
85
1.00M
    es->err_marks[top]--;
86
1.00M
    return 1;
87
7.44M
}
88