From 5135dc03df2e81767e127bd2770bffa5e68ddc4f Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 16 Jun 2009 13:41:01 +0000 Subject: [PATCH] fix seg in some edge cases git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13781 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia_glue.c | 6 ++++-- src/switch_utils.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 3cdd9b3628..4497547d5e 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1662,7 +1662,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) sofia_glue_tech_patch_sdp(tech_pvt); } - if (tech_pvt->dest && (route = strstr(tech_pvt->dest, ";fs_path="))) { + if (tech_pvt->dest && (route = strstr(tech_pvt->dest, ";fs_path=")) && (*(route + 9))) { char *p; route = switch_core_session_strdup(tech_pvt->session, route + 9); @@ -1686,6 +1686,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } route_uri = sofia_overcome_sip_uri_weakness(tech_pvt->session, route_uri, 0, SWITCH_TRUE, NULL); + } else { + route = NULL; } if ((val = switch_channel_get_variable(channel, "sip_route_uri"))) { @@ -1715,7 +1717,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_IF(tech_pvt->route_uri, NUTAG_PROXY(tech_pvt->route_uri)), - TAG_IF(route, SIPTAG_ROUTE_STR(route)), + TAG_IF(!switch_strlen_zero(route), SIPTAG_ROUTE_STR(route)), TAG_IF(!switch_strlen_zero(sendto), NUTAG_PROXY(sendto)), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), diff --git a/src/switch_utils.c b/src/switch_utils.c index de1bf0f87f..9073796b2d 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -1688,6 +1688,10 @@ SWITCH_DECLARE(char *) switch_url_decode(char *s) char *o; unsigned int tmp; + if (switch_strlen_zero(s)) { + return s; + } + for (o = s; *s; s++, o++) { if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) { *o = (char) tmp;