Module: kamailio
Branch: master
Commit: 1b014d65e26a99f9f5d4aea1b27949776f083c2d
URL:
https://github.com/kamailio/kamailio/commit/1b014d65e26a99f9f5d4aea1b279497…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-11-30T09:19:16+01:00
lib/srdb1: memset db connection structure earlier in db_bind_mod()
---
Modified: src/lib/srdb1/db.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1b014d65e26a99f9f5d4aea1b279497…
Patch:
https://github.com/kamailio/kamailio/commit/1b014d65e26a99f9f5d4aea1b279497…
---
diff --git a/src/lib/srdb1/db.c b/src/lib/srdb1/db.c
index 4a250bc819..7d53f70361 100644
--- a/src/lib/srdb1/db.c
+++ b/src/lib/srdb1/db.c
@@ -163,6 +163,12 @@ int db_bind_mod(const str* mod, db_func_t* mydbf)
LM_CRIT("null dbf parameter\n");
return -1;
}
+
+ /* for safety we initialize mydbf with 0 (this will cause
+ * a segfault immediately if someone tries to call a function
+ * from it without checking the return code from bind_dbmod */
+ memset((void*)mydbf, 0, sizeof(db_func_t));
+
if (mod->len > MAX_URL_LENGTH)
{
LM_ERR("SQL URL too long\n");
@@ -178,11 +184,6 @@ int db_bind_mod(const str* mod, db_func_t* mydbf)
memcpy(name+3, mod->s, mod->len);
name[mod->len+3] = 0;
- /* for safety we initialize mydbf with 0 (this will cause
- * a segfault immediately if someone tries to call a function
- * from it without checking the return code from bind_dbmod */
- memset((void*)mydbf, 0, sizeof(db_func_t));
-
p = strchr(name, ':');
if (p) {
len = p - name;