[sr-dev] git:master:05b31ddb: topos: Safety check for database storage

Carsten Bock carsten at ng-voice.com
Mon Jul 10 09:57:37 CEST 2017


Module: kamailio
Branch: master
Commit: 05b31ddbfad71cae5c4cab24b57b1d606c74a7c8
URL: https://github.com/kamailio/kamailio/commit/05b31ddbfad71cae5c4cab24b57b1d606c74a7c8

Author: Carsten Bock <carsten at ng-voice.com>
Committer: Carsten Bock <carsten at ng-voice.com>
Date: 2017-07-10T09:57:20+02:00

topos: Safety check for database storage

---

Modified: src/modules/topos/tps_storage.c

---

Diff:  https://github.com/kamailio/kamailio/commit/05b31ddbfad71cae5c4cab24b57b1d606c74a7c8.diff
Patch: https://github.com/kamailio/kamailio/commit/05b31ddbfad71cae5c4cab24b57b1d606c74a7c8.patch

---

diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index 814593880e..9e2285dda9 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -448,6 +448,11 @@ int tps_db_insert_dialog(tps_data_t *td)
 	db_val_t db_vals[TPS_NR_KEYS];
 	int nr_keys;
 
+	if (_tps_db_handle == NULL) {
+		LM_ERR("No database handle - misconfiguration?\n");
+		goto error;
+	}
+
 	memset(db_keys, 0, TPS_NR_KEYS*sizeof(db_key_t));
 	memset(db_vals, 0, TPS_NR_KEYS*sizeof(db_val_t));
 	nr_keys = 0;
@@ -583,6 +588,11 @@ int tps_db_clean_dialogs(void)
 	db_op_t  db_ops[2];
 	int nr_keys;
 
+	if (_tps_db_handle == NULL) {
+		LM_ERR("No database handle - misconfiguration?\n");
+		return -1;
+	}
+
 	nr_keys = 0;
 
 	LM_DBG("cleaning expired dialog records\n");
@@ -629,6 +639,11 @@ int tps_db_insert_branch(tps_data_t *td)
 	db_val_t db_vals[TPS_NR_KEYS];
 	int nr_keys;
 
+	if (_tps_db_handle == NULL) {
+		LM_ERR("No database handle - misconfiguration?\n");
+		goto error;
+	}
+
 	memset(db_keys, 0, TPS_NR_KEYS*sizeof(db_key_t));
 	memset(db_vals, 0, TPS_NR_KEYS*sizeof(db_val_t));
 	nr_keys = 0;
@@ -730,6 +745,11 @@ int tps_db_clean_branches(void)
 	db_op_t  db_ops[2];
 	int nr_keys;
 
+	if (_tps_db_handle == NULL) {
+		LM_ERR("No database handle - misconfiguration?\n");
+		return -1;
+	}
+
 	nr_keys = 0;
 
 	LM_DBG("cleaning expired branch records\n");




More information about the sr-dev mailing list