Browse Source

htable: safety check for key type and value

- reported by FS#486

(cherry picked from commit f5d9b59ee5aabb1da934ae2ce8101250041c05d1)
(cherry picked from commit 3209d2245cbc3d2def94065aed0ccdab23678a64)
(cherry picked from commit d7e7d76c6911ddd6e7f00fca35451621870a582b)
Daniel-Constantin Mierla 11 years ago
parent
commit
6d50844d70
1 changed files with 5 additions and 1 deletions
  1. 5 1
      modules/htable/ht_db.c

+ 5 - 1
modules/htable/ht_db.c

@@ -204,7 +204,11 @@ int ht_db_load_table(ht_t *ht, str *dbtable, int mode)
 	do {
 		for(i=0; i<RES_ROW_N(db_res); i++)
 		{
-			/* not NULL values enforced in table definition ?!?! */
+			if(RES_ROWS(db_res)[i].values[0].type!=DB1_STRING
+					|| VAL_NULL(&RES_ROWS(db_res)[i].values[0])) {
+				LM_ERR("key type must be string and its value not null\n");
+				goto error;
+			}
 			kname.s = (char*)(RES_ROWS(db_res)[i].values[0].val.string_val);
 			if(kname.s==NULL) {
 				LM_ERR("null key in row %d\n", i);