Browse Source

htable: safety check for key type and value

- reported by FS#486
Daniel-Constantin Mierla 11 years ago
parent
commit
f5d9b59ee5
1 changed files with 5 additions and 1 deletions
  1. 5 1
      modules/htable/ht_db.c

+ 5 - 1
modules/htable/ht_db.c

@@ -198,7 +198,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);