Module: kamailio
Branch: 4.3
Commit: 02ba3dd9fbb41fb3f03fa230672c72acedc39f0d
URL:
https://github.com/kamailio/kamailio/commit/02ba3dd9fbb41fb3f03fa230672c72a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-07-17T12:30:59+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)
---
Modified: modules/permissions/trusted.c
---
Diff:
https://github.com/kamailio/kamailio/commit/02ba3dd9fbb41fb3f03fa230672c72a…
Patch:
https://github.com/kamailio/kamailio/commit/02ba3dd9fbb41fb3f03fa230672c72a…
---
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;