From f6385134083542caf93677b38f868dfee480da72 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Oct 27 2020 18:14:52 +0000 Subject: Add-finalization-safety-check-to-com_err.patch patch_name: Add-finalization-safety-check-to-com_err.patch present_in_specfile: true location_in_specfile: 11 --- diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index d7069a9..7dc02a3 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -26,7 +26,7 @@ static struct et_list *et_list; static k5_mutex_t et_list_lock = K5_MUTEX_PARTIAL_INITIALIZER; -static int terminated = 0; /* for debugging shlib fini sequence errors */ +static int terminated = 0; /* for safety and finalization debugging */ MAKE_INIT_FUNCTION(com_err_initialize); MAKE_FINI_FUNCTION(com_err_terminate); @@ -69,6 +69,7 @@ void com_err_terminate(void) enext = e->next; free(e); } + et_list = NULL; k5_mutex_unlock(&et_list_lock); k5_mutex_destroy(&et_list_lock); terminated = 1; @@ -280,6 +281,10 @@ remove_error_table(const struct error_table *et) { struct et_list **ep, *e; + /* Safety check in case libraries are finalized in the wrong order. */ + if (terminated) + return ENOENT; + if (CALL_INIT_FUNCTION(com_err_initialize)) return 0; k5_mutex_lock(&et_list_lock);