summaryrefslogtreecommitdiff
path: root/res/res_rtp_asterisk.c
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2014-10-09 21:39:12 +0000
committerKevin Harwell <kharwell@digium.com>2014-10-09 21:39:12 +0000
commit6fc4df727956f0aea44622979349fa9031aaf61d (patch)
tree1da1ee080d6f64a09083035b4ca89aeb4c42c06f /res/res_rtp_asterisk.c
parentc6837c236fd1eca33246e634e90a0526d12efc4b (diff)
res_rtp_asterisk: Crash if no candidates received for component
When starting ice if there is not at least one remote ice candidate with an RTP component asterisk will crash. This is due to an assertion in pjnath as it expects at least one candidate with an RTP component. Added a check to make sure at least one candidate contains an RTP component and at least one candidate has an RTCP component. ASTERISK-24383 #close Review: https://reviewboard.asterisk.org/r/4039/ ........ Merged revisions 425031 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425032 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_rtp_asterisk.c')
-rw-r--r--res/res_rtp_asterisk.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 4eabe16d9..3d2a66cde 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -645,7 +645,7 @@ static void ast_rtp_ice_start(struct ast_rtp_instance *instance)
pj_ice_sess_cand candidates[PJ_ICE_MAX_CAND];
struct ao2_iterator i;
struct ast_rtp_engine_ice_candidate *candidate;
- int cand_cnt = 0;
+ int cand_cnt = 0, has_rtp = 0, has_rtcp = 0;
if (!rtp->ice || !rtp->ice_proposed_remote_candidates) {
return;
@@ -677,6 +677,10 @@ static void ast_rtp_ice_start(struct ast_rtp_instance *instance)
while ((candidate = ao2_iterator_next(&i)) && (cand_cnt < PJ_ICE_MAX_CAND)) {
pj_str_t address;
+ /* there needs to be at least one rtp and rtcp candidate in the list */
+ has_rtp |= candidate->id == AST_RTP_ICE_COMPONENT_RTP;
+ has_rtcp |= candidate->id == AST_RTP_ICE_COMPONENT_RTCP;
+
pj_strdup2(rtp->ice->pool, &candidates[cand_cnt].foundation, candidate->foundation);
candidates[cand_cnt].comp_id = candidate->id;
candidates[cand_cnt].prio = candidate->priority;
@@ -707,7 +711,9 @@ static void ast_rtp_ice_start(struct ast_rtp_instance *instance)
ao2_iterator_destroy(&i);
- if (pj_ice_sess_create_check_list(rtp->ice, &ufrag, &passwd, ao2_container_count(rtp->ice_active_remote_candidates), &candidates[0]) == PJ_SUCCESS) {
+ if (has_rtp && has_rtcp &&
+ pj_ice_sess_create_check_list(rtp->ice, &ufrag, &passwd, ao2_container_count(
+ rtp->ice_active_remote_candidates), &candidates[0]) == PJ_SUCCESS) {
ast_test_suite_event_notify("ICECHECKLISTCREATE", "Result: SUCCESS");
pj_ice_sess_start_check(rtp->ice);
pj_timer_heap_poll(timer_heap, NULL);