aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-08 14:45:28 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-08 14:45:28 +0000
commit5546f66403953bb6c9a5a0384860fad8841981e9 (patch)
tree60eec650884ea5db6795f3fe9202a2cf8264a9aa /channels
parent33a2c1be2723cd08673401bfbda8c2af8eafa40e (diff)
- Issue 7101 (mikma) - Don't crash with no From: header in pedantic mode
- Cleanup of get_destination - Don't call uri_decode twice on the same string if you're in a rush ... :-) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@25568 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 07c355221..d67dd6d7f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6802,49 +6802,60 @@ static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq)
return 0;
}
-/*! \brief Find out who the call is for */
+/*! \brief Find out who the call is for
+ We use the INVITE uri to find out
+*/
static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
{
char tmp[256] = "", *uri, *a;
- char tmpf[256], *from;
+ char tmpf[256] = "", *from;
struct sip_request *req;
char *colon;
req = oreq;
if (!req)
req = &p->initreq;
+
+ /* Find the request URI */
if (req->rlPart2)
ast_copy_string(tmp, req->rlPart2, sizeof(tmp));
uri = get_in_brackets(tmp);
- ast_copy_string(tmpf, get_header(req, "From"), sizeof(tmpf));
- if (pedanticsipchecking) {
+ if (pedanticsipchecking)
ast_uri_decode(tmp);
- ast_uri_decode(tmpf);
- }
- from = get_in_brackets(tmpf);
-
if (strncmp(uri, "sip:", 4)) {
ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", uri);
return -1;
}
uri += 4;
+
+ /* Now find the From: caller ID and name */
+ ast_copy_string(tmpf, get_header(req, "From"), sizeof(tmpf));
+ if (!ast_strlen_zero(tmpf)) {
+ if (pedanticsipchecking)
+ ast_uri_decode(tmpf);
+ from = get_in_brackets(tmpf);
+ } else {
+ from = NULL;
+ }
+
if (!ast_strlen_zero(from)) {
if (strncmp(from, "sip:", 4)) {
ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", from);
return -1;
}
from += 4;
- } else
- from = NULL;
-
- if (pedanticsipchecking) {
- ast_uri_decode(uri);
- ast_uri_decode(from);
+ if ((a = strchr(from, ';')))
+ *a = '\0';
+ if ((a = strchr(from, '@'))) {
+ *a = '\0';
+ ast_string_field_set(p, fromdomain, a + 1);
+ } else
+ ast_string_field_set(p, fromdomain, from);
}
- /* Skip any options */
+ /* Skip any options and find the domain */
if ((a = strchr(uri, ';')))
*a = '\0';
@@ -6879,19 +6890,12 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
ast_string_field_set(p, context, domain_context);
}
- if (from) {
- if ((a = strchr(from, ';')))
- *a = '\0';
- if ((a = strchr(from, '@'))) {
- *a = '\0';
- ast_string_field_set(p, fromdomain, a + 1);
- } else
- ast_string_field_set(p, fromdomain, from);
- }
if (sip_debug_test_pvt(p))
ast_verbose("Looking for %s in %s (domain %s)\n", uri, p->context, p->domain);
- /* Return 0 if we have a matching extension */
+ /* Check the dialplan for the username part of the request URI,
+ the domain will be stored in the SIPDOMAIN variable
+ Return 0 if we have a matching extension */
if (ast_exists_extension(NULL, p->context, uri, 1, from) ||
!strcmp(uri, ast_pickup_ext())) {
if (!oreq)
@@ -6899,9 +6903,10 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
return 0;
}
- /* Return 1 for overlap dialling support */
- if (ast_canmatch_extension(NULL, p->context, uri, 1, from) ||
- !strncmp(uri, ast_pickup_ext(),strlen(uri))) {
+ /* Return 1 for pickup extension or overlap dialling support (if we support it) */
+ if((ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP) &&
+ ast_canmatch_extension(NULL, p->context, uri, 1, from)) ||
+ !strncmp(uri, ast_pickup_ext(), strlen(uri))) {
return 1;
}