Module: sip-router
Branch: 3.1
Commit: 3b6a5953a368b1856a6b1eb7bdda62d397291920
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3b6a595…
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
(cherry picked from commit 5cd534834b7ee529adbcef3f758a19ed93d29210)
---
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 0f88500..82495e1 100644
--- a/modules_k/htable/ht_db.c
+++ b/modules_k/htable/ht_db.c
@@ -183,6 +183,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)
@@ -241,6 +245,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 */