From cf5e81ed7b019711da2f1996ec0508184944965f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 30 Jan 2023 15:26:52 +1100 Subject: [PATCH] Cleanup OpenSSL reference on bad option Another exit path that needs to be cleaned up. (cherry picked from commit e27fc4bbc54eaa2db3f3d12b871f8d7dc32298a8) --- bin/dig/dig.c | 1 + bin/dig/dighost.c | 5 +---- bin/dig/dighost.h | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 9ff8b4292c..83eb8d1507 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -2207,6 +2207,7 @@ plus_option(char *option, bool is_batchfile, bool *need_clone, #if !TARGET_OS_IPHONE exit_or_usage: + cleanup_openssl_refs(); digexit(); #endif /* if !TARGET_OS_IPHONE */ } diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 7e46afa9e4..f2a897dc05 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -247,9 +247,6 @@ clear_current_lookup(void); static bool next_origin(dig_lookup_t *oldlookup); -static void -cleanup_openssl_refs(void); - static int count_dots(char *string) { char *s; @@ -4712,7 +4709,7 @@ cancel_all(void) { UNLOCK_LOOKUP; } -static void +void cleanup_openssl_refs(void) { if (tsigkey != NULL) { debug("freeing TSIG key %p", tsigkey); diff --git a/bin/dig/dighost.h b/bin/dig/dighost.h index 593468a049..227c315f51 100644 --- a/bin/dig/dighost.h +++ b/bin/dig/dighost.h @@ -295,6 +295,9 @@ warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); noreturn void digexit(void); +void +cleanup_openssl_refs(void); + void debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);