From 5990539175ac160c5e3d927e1eeecdf5747dc89f Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sat, 14 Jul 2012 12:49:36 +0000 Subject: Fixed #1554: Assertion in ICE when STUN resolution yields a same address as one of the host candidate and there is only one host candidate exists (thanks Claudio De Angelis for the report) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4205 74dad513-b988-da41-8d7b-12977e46ad98 --- pjnath/src/pjnath/ice_strans.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'pjnath') diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c index a19d9b80..b83c7514 100644 --- a/pjnath/src/pjnath/ice_strans.c +++ b/pjnath/src/pjnath/ice_strans.c @@ -503,6 +503,13 @@ static pj_status_t create_comp(pj_ice_strans *ice_st, unsigned comp_id) add_update_turn(ice_st, comp); } + /* It's possible that we end up without any candidates */ + if (comp->cand_cnt == 0) { + PJ_LOG(4,(ice_st->obj_name, + "Error: no candidate is created due to settings")); + return PJ_EINVAL; + } + return PJ_SUCCESS; } @@ -1548,7 +1555,7 @@ static pj_bool_t stun_on_status(pj_stun_sock *stun_sock, if (comp->default_cand > idx) { --comp->default_cand; } else if (comp->default_cand == idx) { - comp->default_cand = !idx; + comp->default_cand = 0; } /* Remove srflx candidate */ @@ -1576,7 +1583,7 @@ static pj_bool_t stun_on_status(pj_stun_sock *stun_sock, /* May not have cand, e.g. when error during init */ if (cand) cand->status = status; - if (!ice_st->cfg.stun.ignore_stun_error) { + if (!ice_st->cfg.stun.ignore_stun_error || comp->cand_cnt==1) { sess_fail(ice_st, PJ_ICE_STRANS_OP_INIT, "STUN binding request failed", status); } else { -- cgit v1.2.3