[Asterisk-code-review] res config sqlite3: Fix crash when loading with invalid config (asterisk[13])
Sean Bright
asteriskteam at digium.com
Wed Feb 15 12:58:11 CST 2017
Sean Bright has uploaded a new change for review. ( https://gerrit.asterisk.org/4957 )
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/57/4957/1
diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c
index 4c4b820..31f5aca 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/4957
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If6a5c0ca718ad428e01a1fb25beb209a9ac18bc6
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
More information about the asterisk-code-review
mailing list