mirror of https://github.com/openssl/openssl.git
ERR: Move ERR_set_mark(), ERR_pop_to_mark() and ERR_clear_last_mark()
Move them to their own source file, so they end up in a separate object file. This allows providers to override their implementation to use the corresponding OSSL_FUNC upcalls without having to reimplement everything from crypto/err/err.c. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17474)
This commit is contained in:
parent
f59d72f027
commit
fbe88706a4
|
@ -1,3 +1,3 @@
|
||||||
LIBS=../../libcrypto
|
LIBS=../../libcrypto
|
||||||
SOURCE[../../libcrypto]=\
|
SOURCE[../../libcrypto]=\
|
||||||
err_blocks.c err.c err_all.c err_all_legacy.c err_prn.c
|
err_blocks.c err_mark.c err.c err_all.c err_all_legacy.c err_prn.c
|
||||||
|
|
|
@ -847,61 +847,6 @@ void ERR_add_error_vdata(int num, va_list args)
|
||||||
OPENSSL_free(str);
|
OPENSSL_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ERR_set_mark(void)
|
|
||||||
{
|
|
||||||
ERR_STATE *es;
|
|
||||||
|
|
||||||
es = ossl_err_get_state_int();
|
|
||||||
if (es == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (es->bottom == es->top)
|
|
||||||
return 0;
|
|
||||||
es->err_marks[es->top]++;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ERR_pop_to_mark(void)
|
|
||||||
{
|
|
||||||
ERR_STATE *es;
|
|
||||||
|
|
||||||
es = ossl_err_get_state_int();
|
|
||||||
if (es == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
while (es->bottom != es->top
|
|
||||||
&& es->err_marks[es->top] == 0) {
|
|
||||||
err_clear(es, es->top, 0);
|
|
||||||
es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (es->bottom == es->top)
|
|
||||||
return 0;
|
|
||||||
es->err_marks[es->top]--;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ERR_clear_last_mark(void)
|
|
||||||
{
|
|
||||||
ERR_STATE *es;
|
|
||||||
int top;
|
|
||||||
|
|
||||||
es = ossl_err_get_state_int();
|
|
||||||
if (es == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
top = es->top;
|
|
||||||
while (es->bottom != top
|
|
||||||
&& es->err_marks[top] == 0) {
|
|
||||||
top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (es->bottom == top)
|
|
||||||
return 0;
|
|
||||||
es->err_marks[top]--;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void err_clear_last_constant_time(int clear)
|
void err_clear_last_constant_time(int clear)
|
||||||
{
|
{
|
||||||
ERR_STATE *es;
|
ERR_STATE *es;
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2022 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define OSSL_FORCE_ERR_STATE
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include "err_local.h"
|
||||||
|
|
||||||
|
int ERR_set_mark(void)
|
||||||
|
{
|
||||||
|
ERR_STATE *es;
|
||||||
|
|
||||||
|
es = ossl_err_get_state_int();
|
||||||
|
if (es == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (es->bottom == es->top)
|
||||||
|
return 0;
|
||||||
|
es->err_marks[es->top]++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ERR_pop_to_mark(void)
|
||||||
|
{
|
||||||
|
ERR_STATE *es;
|
||||||
|
|
||||||
|
es = ossl_err_get_state_int();
|
||||||
|
if (es == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while (es->bottom != es->top
|
||||||
|
&& es->err_marks[es->top] == 0) {
|
||||||
|
err_clear(es, es->top, 0);
|
||||||
|
es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (es->bottom == es->top)
|
||||||
|
return 0;
|
||||||
|
es->err_marks[es->top]--;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ERR_clear_last_mark(void)
|
||||||
|
{
|
||||||
|
ERR_STATE *es;
|
||||||
|
int top;
|
||||||
|
|
||||||
|
es = ossl_err_get_state_int();
|
||||||
|
if (es == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
top = es->top;
|
||||||
|
while (es->bottom != top
|
||||||
|
&& es->err_marks[top] == 0) {
|
||||||
|
top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (es->bottom == top)
|
||||||
|
return 0;
|
||||||
|
es->err_marks[top]--;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue