[Asterisk-code-review] res config sqlite3: Fix crash when loading with invalid config (asterisk[14])

Sean Bright asteriskteam at digium.com
Wed Feb 15 12:58:14 CST 2017


Sean Bright has uploaded a new change for review. ( https://gerrit.asterisk.org/4958 )

Change subject: res_config_sqlite3: Fix crash when loading with invalid config
......................................................................

res_config_sqlite3: Fix crash when loading with invalid config

When ast_config_load() fails with CONFIG_STATUS_FILEINVALID, it has
already destroyed the ast_config struct for us. Trying to do it again
results in a crash.

Change-Id: If6a5c0ca718ad428e01a1fb25beb209a9ac18bc6
---
M res/res_config_sqlite3.c
1 file changed, 12 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/4958/1

diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c
index a306123..26b1db6 100644
--- a/res/res_config_sqlite3.c
+++ b/res/res_config_sqlite3.c
@@ -1122,12 +1122,19 @@
 		return 0;
 	}
 
-	ast_mutex_lock(&config_lock);
+	if (config == CONFIG_STATUS_FILEINVALID) {
+		ast_log(LOG_ERROR, "Invalid config file '%s'\n", config_filename);
+		return 1;
+	}
 
-	if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
-		ast_log(LOG_ERROR, "%s config file '%s'\n",
-			config == CONFIG_STATUS_FILEMISSING ? "Missing" : "Invalid", config_filename);
-	} else {
+	if (config == CONFIG_STATUS_FILEMISSING) {
+		ast_log(LOG_ERROR, "Missing config file '%s'\n", config_filename);
+		ast_config_destroy(config);
+		return 1;
+	}
+
+	ast_mutex_lock(&config_lock);
+	{
 		const char *cat;
 		struct realtime_sqlite3_db *db;
 

-- 
To view, visit https://gerrit.asterisk.org/4958
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6a5c0ca718ad428e01a1fb25beb209a9ac18bc6
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>



More information about the asterisk-code-review mailing list