2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

Merge branch '3869-dig-fails-to-cleanup-openssl-references' into 'main'

Resolve "Dig fails to cleanup OpenSSL references"

Closes #3869

See merge request isc-projects/bind9!7535
This commit is contained in:
Mark Andrews
2023-02-16 00:16:49 +00:00
3 changed files with 25 additions and 15 deletions

View File

@@ -2195,6 +2195,7 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
#if !TARGET_OS_IPHONE #if !TARGET_OS_IPHONE
exit_or_usage: exit_or_usage:
cleanup_openssl_refs();
digexit(); digexit();
#endif /* if !TARGET_OS_IPHONE */ #endif /* if !TARGET_OS_IPHONE */
} }

View File

@@ -2334,6 +2334,7 @@ setup_lookup(dig_lookup_t *lookup) {
clear_current_lookup(); clear_current_lookup();
return (false); return (false);
#else /* if TARGET_OS_IPHONE */ #else /* if TARGET_OS_IPHONE */
cleanup_openssl_refs();
digexit(); digexit();
#endif /* if TARGET_OS_IPHONE */ #endif /* if TARGET_OS_IPHONE */
} }
@@ -4660,6 +4661,25 @@ cancel_all(void) {
} }
} }
void
cleanup_openssl_refs(void) {
if (tsigkey != NULL) {
debug("freeing TSIG key %p", tsigkey);
dns_tsigkey_detach(&tsigkey);
}
if (sig0key != NULL) {
debug("freeing SIG(0) key %p", sig0key);
dst_key_free(&sig0key);
}
if (is_dst_up) {
debug("destroy DST lib");
dst_lib_destroy();
is_dst_up = false;
}
}
/*% /*%
* Destroy all of the libs we are using, and get everything ready for a * Destroy all of the libs we are using, and get everything ready for a
* clean shutdown. * clean shutdown.
@@ -4681,27 +4701,13 @@ destroy_libs(void) {
clear_searchlist(); clear_searchlist();
if (tsigkey != NULL) { cleanup_openssl_refs();
debug("freeing TSIG key %p", tsigkey);
dns_tsigkey_detach(&tsigkey);
}
if (sig0key != NULL) {
debug("freeing SIG(0) key %p", sig0key);
dst_key_free(&sig0key);
}
if (namebuf != NULL) { if (namebuf != NULL) {
debug("freeing key %p", tsigkey); debug("freeing key %p", tsigkey);
isc_buffer_free(&namebuf); isc_buffer_free(&namebuf);
} }
if (is_dst_up) {
debug("destroy DST lib");
dst_lib_destroy();
is_dst_up = false;
}
debug("Removing log context"); debug("Removing log context");
isc_log_destroy(&lctx); isc_log_destroy(&lctx);

View File

@@ -296,6 +296,9 @@ warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
noreturn void noreturn void
digexit(void); digexit(void);
void
cleanup_openssl_refs(void);
void void
debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);