diff options
Diffstat (limited to 'res/res_pjsip_path.c')
-rw-r--r-- | res/res_pjsip_path.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/res/res_pjsip_path.c b/res/res_pjsip_path.c index 47d6a7906..20c9d4366 100644 --- a/res/res_pjsip_path.c +++ b/res/res_pjsip_path.c @@ -40,7 +40,8 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri char *configured_aors, *aor_name; pjsip_sip_uri *sip_uri; char *domain_name; - RAII_VAR(struct ast_str *, id, NULL, ast_free); + char *username; + struct ast_str *id = NULL; if (ast_strlen_zero(endpoint->aors)) { return NULL; @@ -49,6 +50,14 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri sip_uri = pjsip_uri_get_uri(uri); domain_name = ast_alloca(sip_uri->host.slen + 1); ast_copy_pj_str(domain_name, &sip_uri->host, sip_uri->host.slen + 1); + username = ast_alloca(sip_uri->user.slen + 1); + ast_copy_pj_str(username, &sip_uri->user, sip_uri->user.slen + 1); + + /* + * We may want to match without any user options getting + * in the way. + */ + AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(username); configured_aors = ast_strdupa(endpoint->aors); @@ -60,15 +69,16 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri continue; } - if (!pj_strcmp2(&sip_uri->user, aor_name)) { + if (!strcmp(username, aor_name)) { break; } - if (!id && !(id = ast_str_create(sip_uri->user.slen + sip_uri->host.slen + 2))) { - return NULL; + if (!id && !(id = ast_str_create(strlen(username) + sip_uri->host.slen + 2))) { + aor_name = NULL; + break; } - ast_str_set(&id, 0, "%.*s@", (int)sip_uri->user.slen, sip_uri->user.ptr); + ast_str_set(&id, 0, "%s@", username); if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) { ast_str_append(&id, 0, "%s", alias->domain); ao2_cleanup(alias); @@ -77,10 +87,10 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri } if (!strcmp(aor_name, ast_str_buffer(id))) { - ast_free(id); break; } } + ast_free(id); if (ast_strlen_zero(aor_name)) { return NULL; |