diff options
-rw-r--r-- | crypto/err/err_mark.c | 13 | ||||
-rw-r--r-- | doc/man3/ERR_set_mark.pod | 14 | ||||
-rw-r--r-- | include/openssl/err.h.in | 1 | ||||
-rw-r--r-- | util/libcrypto.num | 1 |
4 files changed, 27 insertions, 2 deletions
diff --git a/crypto/err/err_mark.c b/crypto/err/err_mark.c index 82dc4764c4..cb01a1f4f6 100644 --- a/crypto/err/err_mark.c +++ b/crypto/err/err_mark.c @@ -26,6 +26,19 @@ int ERR_set_mark(void) return 1; } +int ERR_pop(void) +{ + ERR_STATE *es; + + es = ossl_err_get_state_int(); + if (es == NULL || es->bottom == es->top) + return 0; + + err_clear(es, es->top, 0); + es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1; + return 1; +} + int ERR_pop_to_mark(void) { ERR_STATE *es; diff --git a/doc/man3/ERR_set_mark.pod b/doc/man3/ERR_set_mark.pod index b2c0f7de0a..d6d715e2f6 100644 --- a/doc/man3/ERR_set_mark.pod +++ b/doc/man3/ERR_set_mark.pod @@ -2,8 +2,8 @@ =head1 NAME -ERR_set_mark, ERR_clear_last_mark, ERR_pop_to_mark, ERR_count_to_mark - set -mark, clear mark and pop errors until mark +ERR_set_mark, ERR_clear_last_mark, ERR_pop_to_mark, ERR_count_to_mark, ERR_pop - +set mark, clear mark and pop errors until mark =head1 SYNOPSIS @@ -13,6 +13,7 @@ mark, clear mark and pop errors until mark int ERR_pop_to_mark(void); int ERR_clear_last_mark(void); int ERR_count_to_mark(void); + int ERR_pop(void); =head1 DESCRIPTION @@ -28,6 +29,9 @@ ERR_count_to_mark() returns the number of entries on the error stack above the most recently marked entry, not including that entry. If there is no mark in the error stack, the number of entries in the error stack is returned. +ERR_pop() unconditionally pops a single error entry from the top of the error +stack (which is the entry obtainable via L<ERR_peek_last_error(3)>). + =head1 RETURN VALUES ERR_set_mark() returns 0 if the error stack is empty, otherwise 1. @@ -38,6 +42,12 @@ error stack, which implies that the stack became empty, otherwise 1. ERR_count_to_mark() returns the number of error stack entries found above the most recent mark, if any, or the total number of error stack entries. +ERR_pop() returns 1 if an error was popped or 0 if the error stack was empty. + +=head1 HISTORY + +ERR_pop() was added in OpenSSL 3.3. + =head1 COPYRIGHT Copyright 2003-2023 The OpenSSL Project Authors. All Rights Reserved. diff --git a/include/openssl/err.h.in b/include/openssl/err.h.in index 1ef09de02e..9143704c09 100644 --- a/include/openssl/err.h.in +++ b/include/openssl/err.h.in @@ -486,6 +486,7 @@ int ERR_set_mark(void); int ERR_pop_to_mark(void); int ERR_clear_last_mark(void); int ERR_count_to_mark(void); +int ERR_pop(void); ERR_STATE *OSSL_ERR_STATE_new(void); void OSSL_ERR_STATE_save(ERR_STATE *es); diff --git a/util/libcrypto.num b/util/libcrypto.num index 60f320c33a..0b72559f86 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -5541,3 +5541,4 @@ OSSL_CMP_HDR_get0_geninfo_ITAVs ? 3_3_0 EXIST::FUNCTION:CMP OSSL_CMP_ITAV_new0_certProfile ? 3_3_0 EXIST::FUNCTION:CMP OSSL_CMP_ITAV_get0_certProfile ? 3_3_0 EXIST::FUNCTION:CMP EVP_DigestSqueeze ? 3_3_0 EXIST::FUNCTION: +ERR_pop ? 3_3_0 EXIST::FUNCTION: |