[Freeswitch-svn] [commit] r6215 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Fri Nov 9 19:47:09 EST 2007
Author: anthm
Date: Fri Nov 9 19:47:09 2007
New Revision: 6215
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
Log:
protection against malformed string
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Fri Nov 9 19:47:09 2007
@@ -506,3 +506,32 @@
void sofia_reg_release_gateway__(const char *file, const char *func, int line, sofia_gateway_t *gateway);
#define sofia_reg_release_gateway(x) sofia_reg_release_gateway__(__FILE__, __SWITCH_FUNC__, __LINE__, x);
+
+#define check_decode(_var, _session) do { \
+ assert(_session); \
+ if (!switch_strlen_zero(_var)) { \
+ int d = 0; \
+ char *p; \
+ if (strchr(_var, '%')) { \
+ char *tmp = switch_core_session_strdup(_session, _var); \
+ switch_url_decode(tmp); \
+ _var = tmp; \
+ d++; \
+ } \
+ if ((p = strchr(_var, '"'))) { \
+ if (!d) { \
+ char *tmp = switch_core_session_strdup(_session, _var); \
+ _var = tmp; \
+ } \
+ if ((p = strchr(_var, '"'))) { \
+ _var = p+1; \
+ } \
+ if ((p = strrchr(_var, '"'))) { \
+ *p = '\0'; \
+ } \
+ } \
+ } \
+ \
+ if(_session) break; \
+ } while(!_session)
+
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Nov 9 19:47:09 2007
@@ -1787,16 +1787,6 @@
return;
}
-#define check_decode(_var, _session) do { \
- assert(_session); \
- if (!switch_strlen_zero(_var) && strchr(_var, '%')) { \
- char *tmp = switch_core_session_strdup(_session, _var); \
- switch_url_decode(tmp); \
- _var = tmp; \
- } \
- if(_session) break; \
- } while(!_session)
-
#define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri")
const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const char *user_var,
@@ -2144,6 +2134,7 @@
dialplan = profile->dialplan;
}
+ check_decode(displayname, session);
tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
from_user,
dialplan,
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Fri Nov 9 19:47:09 2007
@@ -498,6 +498,8 @@
cid_name = caller_profile->caller_id_name;
cid_num = caller_profile->caller_id_number;
sofia_glue_tech_prepare_codecs(tech_pvt);
+ check_decode(cid_name, session);
+ check_decode(cid_num, session);
if (!tech_pvt->from_str) {
tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, "\"%s\" <sip:%s%s%s>",
More information about the Freeswitch-svn
mailing list