summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-10-10 18:21:55 +0000
committerJoshua Colp <jcolp@digium.com>2013-10-10 18:21:55 +0000
commit113c28178214bda05e3b873ad3d05df5288b0920 (patch)
tree0c88605a1c3e14de97351fc2883e072840970178 /res
parentcbbcf1808cbe24753d3c8a23cf596497223f631f (diff)
Perform validation of permanent contacts on AORs in res_pjsip.
........ Merged revisions 400833 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400834 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_pjsip/location.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 4ba945fc9..8569e7a38 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -270,6 +270,24 @@ static int permanent_uri_handler(const struct aco_option *opt, struct ast_variab
{
struct ast_sip_aor *aor = obj;
RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+ pj_pool_t *pool;
+ pj_str_t contact_uri;
+ static const pj_str_t HCONTACT = { "Contact", 7 };
+
+ pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Permanent Contact Validation", 256, 256);
+ if (!pool) {
+ return -1;
+ }
+
+ pj_strdup2_with_null(pool, &contact_uri, var->value);
+ if (!pjsip_parse_hdr(pool, &HCONTACT, contact_uri.ptr, contact_uri.slen, NULL)) {
+ ast_log(LOG_ERROR, "Permanent URI on aor '%s' with contact '%s' failed to parse\n",
+ ast_sorcery_object_get_id(aor), var->value);
+ pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+ return -1;
+ }
+
+ pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
if ((!aor->permanent_contacts && !(aor->permanent_contacts = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL))) ||
!(contact = ast_sorcery_alloc(ast_sip_get_sorcery(), "contact", NULL))) {