Module: kamailio Branch: 4.2 Commit: 21b9fd01edef11ac3d3352115d52b7d0d985d95f URL: https://github.com/kamailio/kamailio/commit/21b9fd01edef11ac3d3352115d52b7d0...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-07-29T12:35:53+02:00
permissions: safety check for trusted hash table
- avoid crash if a db reload is issued in db-only mode - reported Emmanuel Schmidbauer, GH #228
(cherry picked from commit f2958e5861a96e40f0aca05d5d5bd7fa14c2089e) (cherry picked from commit 02ba3dd9fbb41fb3f03fa230672c72acedc39f0d)
---
Modified: modules/permissions/trusted.c
---
Diff: https://github.com/kamailio/kamailio/commit/21b9fd01edef11ac3d3352115d52b7d0... Patch: https://github.com/kamailio/kamailio/commit/21b9fd01edef11ac3d3352115d52b7d0...
---
diff --git a/modules/permissions/trusted.c b/modules/permissions/trusted.c index db20e8f..f42c096 100644 --- a/modules/permissions/trusted.c +++ b/modules/permissions/trusted.c @@ -43,9 +43,9 @@
#define TABLE_VERSION 5
-struct trusted_list ***hash_table; /* Pointer to current hash table pointer */ -struct trusted_list **hash_table_1; /* Pointer to hash table 1 */ -struct trusted_list **hash_table_2; /* Pointer to hash table 2 */ +struct trusted_list ***hash_table = 0; /* Pointer to current hash table pointer */ +struct trusted_list **hash_table_1 = 0; /* Pointer to hash table 1 */ +struct trusted_list **hash_table_2 = 0; /* Pointer to hash table 2 */
static db1_con_t* db_handle = 0; @@ -69,16 +69,21 @@ int reload_trusted_table(void)
char *pattern, *tag;
- cols[0] = &source_col; - cols[1] = &proto_col; - cols[2] = &from_col; - cols[3] = &tag_col; + if (hash_table == 0) { + LM_ERR("in-memory hash table not initialized\n"); + return -1; + }
if (db_handle == 0) { LM_ERR("no connection to database\n"); return -1; }
+ cols[0] = &source_col; + cols[1] = &proto_col; + cols[2] = &from_col; + cols[3] = &tag_col; + if (perm_dbf.use_table(db_handle, &trusted_table) < 0) { LM_ERR("failed to use trusted table\n"); return -1;