Skip to content

Commit

Permalink
Prevent picking 0 as tiebreaker since it would mean no STUN attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Jul 18, 2024
1 parent b5f0929 commit 9d441db
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ juice_agent_t *agent_create(const juice_config_t *config) {
// it has received a 487 response, in which case it MUST change the
// number.
juice_random(&agent->ice_tiebreaker, sizeof(agent->ice_tiebreaker));
if(agent->ice_tiebreaker == 0)
agent->ice_tiebreaker = 1; // prevent picking zero

return agent;

Expand Down Expand Up @@ -1514,7 +1516,11 @@ int agent_process_stun_binding(juice_agent_t *agent, const stun_message_t *msg,
: "controlling");
agent->mode = entry->mode == AGENT_MODE_CONTROLLING ? AGENT_MODE_CONTROLLED
: AGENT_MODE_CONTROLLING;

juice_random(&agent->ice_tiebreaker, sizeof(agent->ice_tiebreaker));
if(agent->ice_tiebreaker == 0)
agent->ice_tiebreaker = 1; // prevent picking zero

agent_update_candidate_pairs(agent); // expires transaction IDs

if (entry->state != AGENT_STUN_ENTRY_STATE_IDLE) { // Check might not be started
Expand Down

0 comments on commit 9d441db

Please sign in to comment.