Coverage Report

Created: 2026-04-01 06:39

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