Use ERR_get_error_all() instead of deprecated ERR_get_error_line_data()

OpenSSL 3.0.0 deprecates the ERR_get_error_line_data() function.

Use ERR_get_error_all() instead of ERR_get_error_line_data() and create
a shim to use the old variant for the older OpenSSL versions which don't
have the newer ERR_get_error_all().
This commit is contained in:
Aram Sargsyan 2021-09-05 09:41:00 +00:00
parent c45d853f44
commit 2563afb920
6 changed files with 56 additions and 2 deletions

View file

@ -628,6 +628,7 @@ AC_CHECK_FUNCS([OPENSSL_init_ssl OPENSSL_init_crypto])
AC_CHECK_FUNCS([CRYPTO_zalloc])
AC_CHECK_FUNCS([EVP_CIPHER_CTX_new EVP_CIPHER_CTX_free])
AC_CHECK_FUNCS([EVP_MD_CTX_new EVP_MD_CTX_free EVP_MD_CTX_reset EVP_MD_CTX_get0_md])
AC_CHECK_FUNCS([ERR_get_error_all])
AC_CHECK_FUNCS([HMAC_CTX_new HMAC_CTX_free HMAC_CTX_reset HMAC_CTX_get_md])
AC_CHECK_FUNCS([SSL_read_ex SSL_peek_ex SSL_write_ex])
AC_CHECK_FUNCS([BIO_read_ex BIO_write_ex])

View file

@ -198,6 +198,8 @@ libdns_la_SOURCES = \
nsec3.c \
nta.c \
openssl_link.c \
openssl_shim.c \
openssl_shim.h \
openssldh_link.c \
opensslecdsa_link.c \
openssleddsa_link.c \

View file

@ -41,6 +41,8 @@
#include <openssl/engine.h>
#endif /* if !defined(OPENSSL_NO_ENGINE) */
#include "openssl_shim.h"
#if !defined(OPENSSL_NO_ENGINE)
static ENGINE *e = NULL;
#endif /* if !defined(OPENSSL_NO_ENGINE) */
@ -160,7 +162,7 @@ dst__openssl_toresult3(isc_logcategory_t *category, const char *funcname,
isc_result_t fallback) {
isc_result_t result;
unsigned long err;
const char *file, *data;
const char *file, *func, *data;
int line, flags;
char buf[256];
@ -174,7 +176,7 @@ dst__openssl_toresult3(isc_logcategory_t *category, const char *funcname,
}
for (;;) {
err = ERR_get_error_line_data(&file, &line, &data, &flags);
err = ERR_get_error_all(&file, &line, &func, &data, &flags);
if (err == 0U) {
goto done;
}

27
lib/dns/openssl_shim.c Normal file
View file

@ -0,0 +1,27 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include "openssl_shim.h"
#include <openssl/err.h>
#if !HAVE_ERR_GET_ERROR_ALL
static const char err_empty_string = '\0';
unsigned long
ERR_get_error_all(const char **file, int *line, const char **func,
const char **data, int *flags) {
if (func != NULL) {
*func = &err_empty_string;
}
return (ERR_get_error_line_data(file, line, data, flags));
}
#endif /* if !HAVE_ERR_GET_ERROR_ALL */

20
lib/dns/openssl_shim.h Normal file
View file

@ -0,0 +1,20 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
#include <openssl/err.h>
#if !HAVE_ERR_GET_ERROR_ALL
unsigned long
ERR_get_error_all(const char **file, int *line, const char **func,
const char **data, int *flags);
#endif /* if !HAVE_ERR_GET_ERROR_ALL */

View file

@ -1269,6 +1269,8 @@
./lib/dns/nsec3.c C 2006,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/dns/nta.c C 2014,2015,2016,2017,2018,2019,2020,2021
./lib/dns/openssl_link.c C.NAI 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2014,2015,2016,2017,2018,2019,2020,2021
./lib/dns/openssl_shim.c C 2021
./lib/dns/openssl_shim.h C 2021
./lib/dns/openssldh_link.c C.NAI 1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/dns/opensslecdsa_link.c C 2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/dns/openssleddsa_link.c C 2017,2018,2019,2020,2021