From: Ondřej Surý Date: Wed, 28 Oct 2020 14:25:44 +0000 (+0100) Subject: Unify lt_dlopen() error handling X-Git-Tag: v9.17.7~38^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e9a58a3e68a7500b581f301ba837563178948c9;p=thirdparty%2Fbind9.git Unify lt_dlopen() error handling Make sure an error gets logged when any lt_dlopen() call in the source tree fails. Also make sure that NULL values returned by lt_dlerror() are replaced with a generic error message to prevent passing NULL as an argument for the %s format specifier. --- diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c index fb9ce8d459f..0f8ff4d33c2 100644 --- a/bin/named/unix/dlz_dlopen_driver.c +++ b/bin/named/unix/dlz_dlopen_driver.c @@ -235,9 +235,13 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[], cd->dl_handle = lt_dlopenext(cd->dl_path); if (cd->dl_handle == NULL) { + const char *errmsg = lt_dlerror(); + if (errmsg == NULL) { + errmsg = "unknown error"; + } dlopen_log(ISC_LOG_ERROR, "dlz_dlopen failed to open library '%s': %s", - cd->dl_path, lt_dlerror()); + cd->dl_path, errmsg); result = ISC_R_FAILURE; goto failed; } diff --git a/lib/dns/dyndb.c b/lib/dns/dyndb.c index e35293ece62..38e320e4cc4 100644 --- a/lib/dns/dyndb.c +++ b/lib/dns/dyndb.c @@ -95,7 +95,7 @@ load_symbol(lt_dlhandle handle, const char *filename, const char *symbol_name, isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR, "failed to lookup symbol %s in " - "dyndb module '%s': %s", + "DynDB module '%s': %s", symbol_name, filename, errmsg); return (ISC_R_FAILURE); } @@ -128,6 +128,15 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname, handle = lt_dlopen(filename); if (handle == NULL) { + const char *errmsg = lt_dlerror(); + if (errmsg == NULL) { + errmsg = "unknown error"; + } + isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, + DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR, + "failed to dlopen() DynDB instance '%s' driver " + "'%s': %s", + instname, filename, errmsg); CHECK(ISC_R_FAILURE); }