Module: sip-router Branch: 3.1 Commit: c9576754926602aa09f5e464a5278c41b608779c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c9576754...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Nov 26 09:54:04 2010 +0100
topoh: more verbose err reporting during init
- check also if mask ip != local ip - should prevent the crashes when mask ip == local ip (cherry picked from commit 11ea0c4de66e40bfa1ba03a351f7ec6bc5f0fbfc)
---
modules/topoh/topoh_mod.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/modules/topoh/topoh_mod.c b/modules/topoh/topoh_mod.c index a1f3fd2..87a8a13 100644 --- a/modules/topoh/topoh_mod.c +++ b/modules/topoh/topoh_mod.c @@ -42,6 +42,7 @@ #include "../../events.h" #include "../../dprint.h" #include "../../ut.h" +#include "../../forward.h" #include "../../parser/msg_parser.h" #include "../../parser/parse_to.h" #include "../../parser/parse_from.h" @@ -110,6 +111,16 @@ static int mod_init(void) { th_cookie_name.len = strlen(th_cookie_name.s); th_ip.len = strlen(th_ip.s); + if(th_ip.len<=0) + { + LM_ERR("mask IP parameter is invalid\n"); + goto error; + } + if(check_self(&th_ip, 0, 0)==1) + { + LM_ERR("mask IP must be different than SIP server local IP\n"); + goto error; + } th_uparam_name.len = strlen(th_uparam_name.s); th_uparam_prefix.len = strlen(th_uparam_prefix.s); th_vparam_name.len = strlen(th_vparam_name.s); @@ -121,18 +132,25 @@ static int mod_init(void) + th_vparam_prefix.len; th_via_prefix.s = (char*)pkg_malloc(th_via_prefix.len+1); if(th_via_prefix.s==NULL) + { + LM_ERR("via prefix parameter is invalid\n"); goto error; + } /* 'sip:' + ip + ';' + param + '=' + prefix (+ '\0') */ th_uri_prefix.len = 4 + th_ip.len + 1 + th_uparam_name.len + 1 + th_uparam_prefix.len; th_uri_prefix.s = (char*)pkg_malloc(th_uri_prefix.len+1); if(th_uri_prefix.s==NULL) + { + LM_ERR("uri prefix parameter is invalid\n"); goto error; + } /* build via prefix */ memcpy(th_via_prefix.s, "SIP/2.0/UDP ", 12); memcpy(th_via_prefix.s+12, th_ip.s, th_ip.len); th_via_prefix.s[12+th_ip.len] = ';'; - memcpy(th_via_prefix.s+12+th_ip.len+1, th_vparam_name.s, th_vparam_name.len); + memcpy(th_via_prefix.s+12+th_ip.len+1, th_vparam_name.s, + th_vparam_name.len); th_via_prefix.s[12+th_ip.len+1+th_vparam_name.len] = '='; memcpy(th_via_prefix.s+12+th_ip.len+1+th_vparam_name.len+1, th_vparam_prefix.s, th_vparam_prefix.len);