From 1b014d65e26a99f9f5d4aea1b27949776f083c2d Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 30 Nov 2018 09:19:16 +0100 Subject: [PATCH] lib/srdb1: memset db connection structure earlier in db_bind_mod() --- src/lib/srdb1/db.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/srdb1/db.c b/src/lib/srdb1/db.c index 4a250bc819e..7d53f703615 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;