From e1486f20763b7d52b6394b436fde121f01905111 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 5 Feb 2016 21:30:14 +0000 Subject: agent: Use provided CandidatePair rather than re-finding a pair MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In priv_update_selected_pair(), commit 57393333 changed the code to re-find a CandidatePair matching the given lfoundation and rfoundation. However, the foundation does not uniquely identify candidate pairs, and if we’re aiming to set a specific candidate pair as the selected pair, this could result in the wrong pair being selected. This can happen when handling multiple similar candidate pairs, such as when generating peer reflexive candidates from multiple sources. See https://tools.ietf.org/html/rfc5245#section-2.4. Originally spotted by Fabrice Bellet in https://phabricator.freedesktop.org/T3557. Differential Revision: https://phabricator.freedesktop.org/D742 --- agent/conncheck.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/agent/conncheck.c b/agent/conncheck.c index 60d2fbf..fb311b6 100644 --- a/agent/conncheck.c +++ b/agent/conncheck.c @@ -1207,17 +1207,20 @@ static void priv_limit_conn_check_list_size (GSList *conncheck_list, guint upper */ static gboolean priv_update_selected_pair (NiceAgent *agent, NiceComponent *component, CandidateCheckPair *pair) { - CandidatePair cpair; + CandidatePair cpair = { 0, }; g_assert (component); g_assert (pair); - if (pair->priority > component->selected_pair.priority && - nice_component_find_pair (component, agent, pair->local->foundation, - pair->remote->foundation, &cpair)) { + if (pair->priority > component->selected_pair.priority) { nice_debug ("Agent %p : changing SELECTED PAIR for component %u: %s:%s " "(prio:%" G_GUINT64_FORMAT ").", agent, component->id, pair->local->foundation, pair->remote->foundation, pair->priority); + cpair.local = pair->local; + cpair.remote = pair->remote; + cpair.priority = pair->priority; + /* cpair.keepalive is not used by nice_component_update_selected_pair() */ + nice_component_update_selected_pair (component, &cpair); priv_conn_keepalive_tick_unlocked (agent); -- cgit v1.2.1