Module: kamailio
Branch: master
Commit: 1891dcb958100b5383f40278c4d675474d309df4
URL:
https://github.com/kamailio/kamailio/commit/1891dcb958100b5383f40278c4d6754…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-22T08:33:22+02:00
pdt: reorder checks to avoid null access
---
Modified: src/modules/pdt/pdt.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1891dcb958100b5383f40278c4d6754…
Patch:
https://github.com/kamailio/kamailio/commit/1891dcb958100b5383f40278c4d6754…
---
diff --git a/src/modules/pdt/pdt.c b/src/modules/pdt/pdt.c
index 6505d8a3d5..09eacace4f 100644
--- a/src/modules/pdt/pdt.c
+++ b/src/modules/pdt/pdt.c
@@ -617,21 +617,25 @@ int pdt_load_db(void)
{
/* check for NULL values ?!?! */
sdomain.s = (char*)(RES_ROWS(db_res)[i].values[0].val.string_val);
- sdomain.len = strlen(sdomain.s);
-
p.s = (char*)(RES_ROWS(db_res)[i].values[1].val.string_val);
- p.len = strlen(p.s);
-
d.s = (char*)(RES_ROWS(db_res)[i].values[2].val.string_val);
+
+ if(p.s==NULL || d.s==NULL || sdomain.s==NULL)
+ {
+ LM_ERR("Error - bad values in db\n");
+ continue;
+ }
+
+ sdomain.len = strlen(sdomain.s);
+ p.len = strlen(p.s);
d.len = strlen(d.s);
- if(p.s==NULL || d.s==NULL || sdomain.s==NULL ||
- p.len<=0 || d.len<=0 || sdomain.len<=0)
+ if(p.len<=0 || d.len<=0 || sdomain.len<=0)
{
LM_ERR("Error - bad values in db\n");
continue;
}
-
+
if(pdt_check_domain!=0 && _ptree_new!=NULL
&& pdt_check_pd(_ptree_new, &sdomain, &p, &d)==1)
{