diff options
author | Joshua Colp <jcolp@digium.com> | 2013-10-10 12:26:20 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-10-10 12:26:20 +0000 |
commit | cbbcf1808cbe24753d3c8a23cf596497223f631f (patch) | |
tree | 48f55f5400f076f69f2ba69597c5d6497c9eaa5f /res/res_pjsip | |
parent | fcf6c846662390afa501d9e5432e6d08bcdc82da (diff) |
Fix an assertion in res_pjsip when specifying an invalid outbound proxy.
This change fixes two issues when setting an outbound proxy:
1. The outbound proxy URI was not parsed and validated during configuration.
2. If an outgoing dialog was created and the outbound proxy could not be set an assertion would
occur because the usage count on the dialog was not decremented.
The documentation has also been updated to specify that a full URI must be specified for
the outbound proxy.
(closes issue ASTERISK-22672)
Reported by: Antti Yrjola
........
Merged revisions 400824 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400825 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip')
-rw-r--r-- | res/res_pjsip/pjsip_configuration.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 151ab1016..0f98a65ae 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -595,6 +595,28 @@ static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *o return -1; } + if (!ast_strlen_zero(endpoint->outbound_proxy)) { + pj_pool_t *pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Outbound Proxy Validation", 256, 256); + static const pj_str_t ROUTE_HNAME = { "Route", 5 }; + pj_str_t tmp; + + if (!pool) { + ast_log(LOG_ERROR, "Could not allocate pool for outbound proxy validation on '%s'\n", + ast_sorcery_object_get_id(endpoint)); + return -1; + } + + pj_strdup2_with_null(pool, &tmp, endpoint->outbound_proxy); + if (!pjsip_parse_hdr(pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL)) { + ast_log(LOG_ERROR, "Invalid outbound proxy '%s' specified on endpoint '%s'\n", + endpoint->outbound_proxy, ast_sorcery_object_get_id(endpoint)); + pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool); + return -1; + } + + pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool); + } + return 0; } |