Coverage Report

Created: 2026-02-22 06:11

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
1
{
15
1
    ERR_STATE *es;
16
17
1
    es = ossl_err_get_state_int();
18
1
    if (es == NULL)
19
0
        return 0;
20
21
1
    if (es->bottom == es->top)
22
1
        return 0;
23
0
    es->err_marks[es->top]++;
24
0
    return 1;
25
1
}
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
1
{
42
1
    ERR_STATE *es;
43
44
1
    es = ossl_err_get_state_int();
45
1
    if (es == NULL)
46
0
        return 0;
47
48
4
    while (es->bottom != es->top
49
3
        && es->err_marks[es->top] == 0) {
50
3
        err_clear(es, es->top, 0);
51
3
        es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
52
3
    }
53
54
1
    if (es->bottom == es->top)
55
1
        return 0;
56
0
    es->err_marks[es->top]--;
57
0
    return 1;
58
1
}
59
60
int ERR_count_to_mark(void)
61
0
{
62
0
    ERR_STATE *es;
63
0
    int count = 0, top;
64
65
0
    es = ossl_err_get_state_int();
66
0
    if (es == NULL)
67
0
        return 0;
68
69
0
    top = es->top;
70
0
    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
0
    return count;
77
0
}
78
79
int ERR_clear_last_mark(void)
80
0
{
81
0
    ERR_STATE *es;
82
0
    int top;
83
84
0
    es = ossl_err_get_state_int();
85
0
    if (es == NULL)
86
0
        return 0;
87
88
0
    top = es->top;
89
0
    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
0
    if (es->bottom == top)
95
0
        return 0;
96
0
    es->err_marks[top]--;
97
0
    return 1;
98
0
}