Coverage Report

Created: 2023-09-25 06:45

/src/openssl/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
9.70M
{
17
9.70M
    ERR_STATE *es;
18
19
9.70M
    es = ossl_err_get_state_int();
20
9.70M
    if (es == NULL)
21
0
        return 0;
22
23
9.70M
    if (es->bottom == es->top)
24
7.65M
        return 0;
25
2.05M
    es->err_marks[es->top]++;
26
2.05M
    return 1;
27
9.70M
}
28
29
int ERR_pop_to_mark(void)
30
55.5M
{
31
55.5M
    ERR_STATE *es;
32
33
55.5M
    es = ossl_err_get_state_int();
34
55.5M
    if (es == NULL)
35
0
        return 0;
36
37
109M
    while (es->bottom != es->top
38
109M
           && es->err_marks[es->top] == 0) {
39
54.1M
        err_clear(es, es->top, 0);
40
54.1M
        es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
41
54.1M
    }
42
43
55.5M
    if (es->bottom == es->top)
44
54.2M
        return 0;
45
1.24M
    es->err_marks[es->top]--;
46
1.24M
    return 1;
47
55.5M
}
48
49
int ERR_count_to_mark(void)
50
0
{
51
0
    ERR_STATE *es;
52
0
    int count = 0, top;
53
54
0
    es = ossl_err_get_state_int();
55
0
    if (es == NULL)
56
0
        return 0;
57
58
0
    top = es->top;
59
0
    while (es->bottom != top
60
0
           && es->err_marks[top] == 0) {
61
0
        ++count;
62
0
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
63
0
    }
64
65
0
    return count;
66
0
}
67
68
int ERR_clear_last_mark(void)
69
1.71M
{
70
1.71M
    ERR_STATE *es;
71
1.71M
    int top;
72
73
1.71M
    es = ossl_err_get_state_int();
74
1.71M
    if (es == NULL)
75
0
        return 0;
76
77
1.71M
    top = es->top;
78
4.15M
    while (es->bottom != top
79
4.15M
           && es->err_marks[top] == 0) {
80
2.44M
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
81
2.44M
    }
82
83
1.71M
    if (es->bottom == top)
84
1.14M
        return 0;
85
572k
    es->err_marks[top]--;
86
572k
    return 1;
87
1.71M
}
88