/src/openssl32/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 | 165M | { |
17 | 165M | ERR_STATE *es; |
18 | | |
19 | 165M | es = ossl_err_get_state_int(); |
20 | 165M | if (es == NULL) |
21 | 0 | return 0; |
22 | | |
23 | 165M | if (es->bottom == es->top) |
24 | 159M | return 0; |
25 | 6.48M | es->err_marks[es->top]++; |
26 | 6.48M | return 1; |
27 | 165M | } |
28 | | |
29 | | int ERR_pop_to_mark(void) |
30 | 307M | { |
31 | 307M | ERR_STATE *es; |
32 | | |
33 | 307M | es = ossl_err_get_state_int(); |
34 | 307M | if (es == NULL) |
35 | 0 | return 0; |
36 | | |
37 | 540M | while (es->bottom != es->top |
38 | 540M | && es->err_marks[es->top] == 0) { |
39 | 233M | err_clear(es, es->top, 0); |
40 | 233M | es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1; |
41 | 233M | } |
42 | | |
43 | 307M | if (es->bottom == es->top) |
44 | 303M | return 0; |
45 | 4.04M | es->err_marks[es->top]--; |
46 | 4.04M | return 1; |
47 | 307M | } |
48 | | |
49 | | int ERR_count_to_mark(void) |
50 | 62.7M | { |
51 | 62.7M | ERR_STATE *es; |
52 | 62.7M | int count = 0, top; |
53 | | |
54 | 62.7M | es = ossl_err_get_state_int(); |
55 | 62.7M | if (es == NULL) |
56 | 0 | return 0; |
57 | | |
58 | 62.7M | top = es->top; |
59 | 62.7M | while (es->bottom != top |
60 | 62.7M | && es->err_marks[top] == 0) { |
61 | 25.3k | ++count; |
62 | 25.3k | top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1; |
63 | 25.3k | } |
64 | | |
65 | 62.7M | return count; |
66 | 62.7M | } |
67 | | |
68 | | int ERR_clear_last_mark(void) |
69 | 15.6M | { |
70 | 15.6M | ERR_STATE *es; |
71 | 15.6M | int top; |
72 | | |
73 | 15.6M | es = ossl_err_get_state_int(); |
74 | 15.6M | if (es == NULL) |
75 | 0 | return 0; |
76 | | |
77 | 15.6M | top = es->top; |
78 | 23.1M | while (es->bottom != top |
79 | 23.1M | && es->err_marks[top] == 0) { |
80 | 7.46M | top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1; |
81 | 7.46M | } |
82 | | |
83 | 15.6M | if (es->bottom == top) |
84 | 13.7M | return 0; |
85 | 1.95M | es->err_marks[top]--; |
86 | 1.95M | return 1; |
87 | 15.6M | } |
88 | | |