From: Mark Andrews Date: Sun, 7 Aug 2022 11:41:18 +0000 (+1000) Subject: Report file and line when converting OpenSSL errors X-Git-Tag: v9.19.12~38^2~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba3425564842839d624a5fc8b1736a436dc2adc2;p=thirdparty%2Fbind9.git Report file and line when converting OpenSSL errors This provides more detail about which instance of specific OpenSSL calls that have failed by reporting the file name and line numbers involved when dst__openssl_toresult2 and dst__openssl_toresult3 are called. --- diff --git a/lib/dns/dst_openssl.h b/lib/dns/dst_openssl.h index ad137706328..b7541fd0e6d 100644 --- a/lib/dns/dst_openssl.h +++ b/lib/dns/dst_openssl.h @@ -29,12 +29,17 @@ ISC_LANG_BEGINDECLS isc_result_t dst__openssl_toresult(isc_result_t fallback); +#define dst__openssl_toresult2(A, B) \ + dst___openssl_toresult2(A, B, __FILE__, __LINE__) isc_result_t -dst__openssl_toresult2(const char *funcname, isc_result_t fallback); +dst___openssl_toresult2(const char *funcname, isc_result_t fallback, + const char *file, int line); +#define dst__openssl_toresult3(A, B, C) \ + dst___openssl_toresult3(A, B, C, __FILE__, __LINE__) isc_result_t -dst__openssl_toresult3(isc_logcategory_t *category, const char *funcname, - isc_result_t fallback); +dst___openssl_toresult3(isc_logcategory_t *category, const char *funcname, + isc_result_t fallback, const char *file, int line); #if !defined(OPENSSL_NO_ENGINE) && OPENSSL_API_LEVEL < 30000 ENGINE * diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index 815ee32311e..3e624d57105 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -175,24 +175,26 @@ dst__openssl_toresult(isc_result_t fallback) { } isc_result_t -dst__openssl_toresult2(const char *funcname, isc_result_t fallback) { - return (dst__openssl_toresult3(DNS_LOGCATEGORY_GENERAL, funcname, - fallback)); +dst___openssl_toresult2(const char *funcname, isc_result_t fallback, + const char *file, int line) { + return (dst___openssl_toresult3(DNS_LOGCATEGORY_GENERAL, funcname, + fallback, file, line)); } isc_result_t -dst__openssl_toresult3(isc_logcategory_t *category, const char *funcname, - isc_result_t fallback) { +dst___openssl_toresult3(isc_logcategory_t *category, const char *funcname, + isc_result_t fallback, const char *file, int line) { isc_result_t result; unsigned long err; - const char *file, *func, *data; - int line, flags; + const char *func, *data; + int flags; char buf[256]; result = toresult(fallback); isc_log_write(dns_lctx, category, DNS_LOGMODULE_CRYPTO, ISC_LOG_WARNING, - "%s failed (%s)", funcname, isc_result_totext(result)); + "%s (%s:%d) failed (%s)", funcname, file, line, + isc_result_totext(result)); if (result == ISC_R_NOMEMORY) { goto done;