From 1a9c2d7545a4bafd7a601a8983192c4861d89c68 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Wed, 31 Jul 2019 19:08:37 +0100 Subject: [PATCH] Exit on failure to initialise a dynamic DB backend The dynamic DB backend does a lot of checks to ensure it can load the requested backend successfully, but didn't actually check that it initialised correctly. Bomb out with a graceful error message if this happens rather than leading the caller to think everything is ok. --- keydb_dynamic.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/keydb_dynamic.c b/keydb_dynamic.c index 9e4e3bc..ef42fbe 100644 --- a/keydb_dynamic.c +++ b/keydb_dynamic.c @@ -291,11 +291,20 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg, soname = NULL; exit(EXIT_FAILURE); } - free(soname); - soname = NULL; privctx->loadeddbctx = backend_init(dbcfg, readonly); + if (privctx->loadeddbctx == NULL) { + logthing(LOGTHING_CRITICAL, + "Failed to initialise dynamic backend: %s", + soname); + free(soname); + soname = NULL; + exit(EXIT_FAILURE); + } + free(soname); + soname = NULL; + if (privctx->loadeddbctx != NULL) { dbctx->cleanupdb = dynamic_cleanupdb; dbctx->starttrans = dynamic_starttrans; -- 2.39.5