Coverage Report

Created: 2026-03-09 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/err/err_mark.c
Line
Count
Source
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
#include <openssl/err.h>
11
#include "err_local.h"
12
13
int ERR_set_mark(void)
14
112
{
15
112
    ERR_STATE *es;
16
17
112
    es = ossl_err_get_state_int();
18
112
    if (es == NULL)
19
0
        return 0;
20
21
112
    if (es->bottom == es->top)
22
112
        return 0;
23
0
    es->err_marks[es->top]++;
24
0
    return 1;
25
112
}
26
27
int ERR_pop(void)
28
0
{
29
0
    ERR_STATE *es;
30
31
0
    es = ossl_err_get_state_int();
32
0
    if (es == NULL || es->bottom == es->top)
33
0
        return 0;
34
35
0
    err_clear(es, es->top, 0);
36
0
    es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
37
0
    return 1;
38
0
}
39
40
int ERR_pop_to_mark(void)
41
48
{
42
48
    ERR_STATE *es;
43
44
48
    es = ossl_err_get_state_int();
45
48
    if (es == NULL)
46
0
        return 0;
47
48
96
    while (es->bottom != es->top
49
48
        && es->err_marks[es->top] == 0) {
50
48
        err_clear(es, es->top, 0);
51
48
        es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
52
48
    }
53
54
48
    if (es->bottom == es->top)
55
48
        return 0;
56
0
    es->err_marks[es->top]--;
57
0
    return 1;
58
48
}
59
60
int ERR_count_to_mark(void)
61
16
{
62
16
    ERR_STATE *es;
63
16
    int count = 0, top;
64
65
16
    es = ossl_err_get_state_int();
66
16
    if (es == NULL)
67
0
        return 0;
68
69
16
    top = es->top;
70
16
    while (es->bottom != top
71
0
        && es->err_marks[top] == 0) {
72
0
        ++count;
73
0
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
74
0
    }
75
76
16
    return count;
77
16
}
78
79
int ERR_clear_last_mark(void)
80
64
{
81
64
    ERR_STATE *es;
82
64
    int top;
83
84
64
    es = ossl_err_get_state_int();
85
64
    if (es == NULL)
86
0
        return 0;
87
88
64
    top = es->top;
89
64
    while (es->bottom != top
90
0
        && es->err_marks[top] == 0) {
91
0
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
92
0
    }
93
94
64
    if (es->bottom == top)
95
64
        return 0;
96
0
    es->err_marks[top]--;
97
0
    return 1;
98
64
}