Skip to content

Commit

Permalink
permissions: safety check for trusted hash table
Browse files Browse the repository at this point in the history
- avoid crash if a db reload is issued in db-only mode
- reported Emmanuel Schmidbauer, GH #228

(cherry picked from commit f2958e5)
(cherry picked from commit 02ba3dd)
  • Loading branch information
miconda committed Jul 29, 2015
1 parent 2ee8481 commit 21b9fd0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions modules/permissions/trusted.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 21b9fd0

Please sign in to comment.