summaryrefslogtreecommitdiff
path: root/res/res_pjsip/location.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2014-01-03 17:27:08 +0000
committerJoshua Colp <jcolp@digium.com>2014-01-03 17:27:08 +0000
commit0ae89e7b7e52453b080e945817fe310dc0586b62 (patch)
treeb0f3fe9bfd54fe8103dc3cc290fcc37590b307f2 /res/res_pjsip/location.c
parentf0f23655c9eec18df2f7a1215335e9f7d47e5a06 (diff)
res_pjsip: Ensure more URI validation happens in pj threads.
........ Merged revisions 404737 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404738 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip/location.c')
-rw-r--r--res/res_pjsip/location.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 3bd4dea10..31eaeeee4 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -225,11 +225,10 @@ static int expiration_struct2str(const void *obj, const intptr_t *args, char **b
return (ast_asprintf(buf, "%lu", contact->expiration_time.tv_sec) < 0) ? -1 : 0;
}
-/*! \brief Custom handler for permanent URIs */
-static int permanent_uri_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+/*! \brief Helper function which validates a permanent contact */
+static int permanent_contact_validate(void *data)
{
- struct ast_sip_aor *aor = obj;
- RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+ const char *value = data;
pj_pool_t *pool;
pj_str_t contact_uri;
static const pj_str_t HCONTACT = { "Contact", 7 };
@@ -239,15 +238,27 @@ static int permanent_uri_handler(const struct aco_option *opt, struct ast_variab
return -1;
}
- pj_strdup2_with_null(pool, &contact_uri, var->value);
+ pj_strdup2_with_null(pool, &contact_uri, 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);
+ return 0;
+}
+
+/*! \brief Custom handler for permanent URIs */
+static int permanent_uri_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+ struct ast_sip_aor *aor = obj;
+ RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+
+ if (ast_sip_push_task_synchronous(NULL, permanent_contact_validate, (char*)var->value)) {
+ ast_log(LOG_ERROR, "Permanent URI on aor '%s' with contact '%s' failed to parse\n",
+ ast_sorcery_object_get_id(aor), var->value);
+ return -1;
+ }
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))) {