mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 02:32:03 -04:00
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.
This commit is contained in:
parent
0f49b02fc5
commit
4e9a58a3e6
2 changed files with 15 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue