Module: sip-router
Branch: master
Commit: 5cd534834b7ee529adbcef3f758a19ed93d29210
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5cd5348…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Apr 16 15:21:32 2011 +0200
htable: safety check for null db values
- with some db engines the non-null condition might not be enforced,
resulting in working with null values
- reported by Eric Hiller
---
modules_k/htable/ht_db.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/modules_k/htable/ht_db.c b/modules_k/htable/ht_db.c
index 7addf81..3808b51 100644
--- a/modules_k/htable/ht_db.c
+++ b/modules_k/htable/ht_db.c
@@ -199,6 +199,10 @@ int ht_db_load_table(ht_t *ht, str *dbtable, int mode)
cnt++;
/* not NULL values enforced in table definition ?!?! */
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);
+ goto error;
+ }
kname.len = strlen(kname.s);
ktype = RES_ROWS(db_res)[i].values[1].val.int_val;
if(ktype==0 && last_ktype==1)
@@ -257,6 +261,10 @@ int ht_db_load_table(ht_t *ht, str *dbtable, int mode)
last_ktype = ktype;
vtype = RES_ROWS(db_res)[i].values[2].val.int_val;
kvalue.s = (char*)(RES_ROWS(db_res)[i].values[3].val.string_val);
+ if(kvalue.s==NULL) {
+ LM_ERR("null value in row %d\n", i);
+ goto error;
+ }
kvalue.len = strlen(kvalue.s);
/* add to hash */