/src/openssl/crypto/err/err_mark.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2003-2022 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 | 819k | { |
17 | 819k | ERR_STATE *es; |
18 | | |
19 | 819k | es = ossl_err_get_state_int(); |
20 | 819k | if (es == NULL) |
21 | 0 | return 0; |
22 | | |
23 | 819k | if (es->bottom == es->top) |
24 | 817k | return 0; |
25 | 2.65k | es->err_marks[es->top]++; |
26 | 2.65k | return 1; |
27 | 819k | } |
28 | | |
29 | | int ERR_pop_to_mark(void) |
30 | 783k | { |
31 | 783k | ERR_STATE *es; |
32 | | |
33 | 783k | es = ossl_err_get_state_int(); |
34 | 783k | if (es == NULL) |
35 | 0 | return 0; |
36 | | |
37 | 963k | while (es->bottom != es->top |
38 | 963k | && es->err_marks[es->top] == 0) { |
39 | 180k | err_clear(es, es->top, 0); |
40 | 180k | es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1; |
41 | 180k | } |
42 | | |
43 | 783k | if (es->bottom == es->top) |
44 | 780k | return 0; |
45 | 2.30k | es->err_marks[es->top]--; |
46 | 2.30k | return 1; |
47 | 783k | } |
48 | | |
49 | | int ERR_clear_last_mark(void) |
50 | 39.0k | { |
51 | 39.0k | ERR_STATE *es; |
52 | 39.0k | int top; |
53 | | |
54 | 39.0k | es = ossl_err_get_state_int(); |
55 | 39.0k | if (es == NULL) |
56 | 0 | return 0; |
57 | | |
58 | 39.0k | top = es->top; |
59 | 40.9k | while (es->bottom != top |
60 | 40.9k | && es->err_marks[top] == 0) { |
61 | 1.88k | top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1; |
62 | 1.88k | } |
63 | | |
64 | 39.0k | if (es->bottom == top) |
65 | 38.7k | return 0; |
66 | 317 | es->err_marks[top]--; |
67 | 317 | return 1; |
68 | 39.0k | } |
69 | | |