Coverage Report

Created: 2026-10-28 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/crypto/err/err_mark.c
Line
Count
Source
1
/*
2
 * Copyright 2003-2026 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
549M
{
15
549M
    ERR_STATE *es;
16
17
549M
    es = ossl_err_get_state_int(0);
18
549M
    if (es == NULL)
19
0
        return 0;
20
21
549M
    if (es->bottom == es->top)
22
360M
        return 0;
23
188M
    es->err_marks[es->top]++;
24
188M
    return 1;
25
549M
}
26
27
int ERR_pop(void)
28
0
{
29
0
    ERR_STATE *es;
30
31
0
    es = ossl_err_get_state_int(0);
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
523M
{
42
523M
    ERR_STATE *es;
43
44
523M
    es = ossl_err_get_state_int(0);
45
523M
    if (es == NULL)
46
0
        return 0;
47
48
964M
    while (es->bottom != es->top
49
622M
        && es->err_marks[es->top] == 0) {
50
441M
        err_clear(es, es->top, 0);
51
441M
        es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
52
441M
    }
53
54
523M
    if (es->bottom == es->top)
55
342M
        return 0;
56
181M
    es->err_marks[es->top]--;
57
181M
    return 1;
58
523M
}
59
60
int ERR_count_to_mark(void)
61
71.2M
{
62
71.2M
    ERR_STATE *es;
63
71.2M
    int count = 0, top;
64
65
71.2M
    es = ossl_err_get_state_int(1);
66
71.2M
    if (es == NULL)
67
0
        return 0;
68
69
71.2M
    top = es->top;
70
71.2M
    while (es->bottom != top
71
3.89M
        && es->err_marks[top] == 0) {
72
56.8k
        ++count;
73
56.8k
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
74
56.8k
    }
75
76
71.2M
    return count;
77
71.2M
}
78
79
int ERR_clear_last_mark(void)
80
25.5M
{
81
25.5M
    ERR_STATE *es;
82
25.5M
    int top;
83
84
25.5M
    es = ossl_err_get_state_int(0);
85
25.5M
    if (es == NULL)
86
0
        return 0;
87
88
25.5M
    top = es->top;
89
34.7M
    while (es->bottom != top
90
15.7M
        && es->err_marks[top] == 0) {
91
9.23M
        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
92
9.23M
    }
93
94
25.5M
    if (es->bottom == top)
95
18.9M
        return 0;
96
6.53M
    es->err_marks[top]--;
97
6.53M
    return 1;
98
25.5M
}