ERR: Add ERR_pop()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22674)
This commit is contained in:
Hugo Landau 2023-11-09 10:27:14 +00:00
parent 0225d42bce
commit 5304d56335
4 changed files with 27 additions and 2 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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);

View File

@ -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: