Commit 4d4cbcb8 authored by Youness Alaoui's avatar Youness Alaoui

Verify the return value of stun_agent_finish_message and similar functions

parent e2f46325
...@@ -594,6 +594,7 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent) ...@@ -594,6 +594,7 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
g_free (password); g_free (password);
} }
if (buf_len > 0) {
stun_timer_start (&p->keepalive.timer); stun_timer_start (&p->keepalive.timer);
/* send the conncheck */ /* send the conncheck */
...@@ -614,26 +615,28 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent) ...@@ -614,26 +615,28 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
agent_timeout_add_with_context (p->keepalive.agent, agent_timeout_add_with_context (p->keepalive.agent,
stun_timer_remainder (&p->keepalive.timer), stun_timer_remainder (&p->keepalive.timer),
priv_conn_keepalive_retransmissions_tick, p); priv_conn_keepalive_retransmissions_tick, p);
} } else {
if (buf_len == 0)
++errors; ++errors;
}
}
} else { } else {
buf_len = stun_usage_bind_keepalive (&agent->stun_agent, buf_len = stun_usage_bind_keepalive (&agent->stun_agent,
&p->keepalive.stun_message, p->keepalive.stun_buffer, &p->keepalive.stun_message, p->keepalive.stun_buffer,
sizeof(p->keepalive.stun_buffer)); sizeof(p->keepalive.stun_buffer));
if (buf_len > 0) {
nice_socket_send (p->local->sockptr, &p->remote->addr, buf_len, nice_socket_send (p->local->sockptr, &p->remote->addr, buf_len,
(gchar *)p->keepalive.stun_buffer); (gchar *)p->keepalive.stun_buffer);
nice_debug ("Agent %p : stun_bind_keepalive for pair %p res %d.", nice_debug ("Agent %p : stun_bind_keepalive for pair %p res %d.",
agent, p, (int) buf_len); agent, p, (int) buf_len);
if (buf_len == 0) } else {
++errors; ++errors;
} }
} }
} }
} }
}
/* case 2: connectivity establishment ongoing /* case 2: connectivity establishment ongoing
* (ref ICE sect 4.1.1.4 "Keeping Candidates Alive" ID-19) */ * (ref ICE sect 4.1.1.4 "Keeping Candidates Alive" ID-19) */
...@@ -1543,6 +1546,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -1543,6 +1546,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
g_free (password); g_free (password);
} }
if (buffer_len > 0) {
stun_timer_start (&pair->timer); stun_timer_start (&pair->timer);
/* send the conncheck */ /* send the conncheck */
...@@ -1553,6 +1557,11 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -1553,6 +1557,11 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
/* note: convert from milli to microseconds for g_time_val_add() */ /* note: convert from milli to microseconds for g_time_val_add() */
g_get_current_time (&pair->next_tick); g_get_current_time (&pair->next_tick);
g_time_val_add (&pair->next_tick, timeout * 1000); g_time_val_add (&pair->next_tick, timeout * 1000);
} else {
pair->stun_message.buffer = NULL;
pair->stun_message.buffer_len = 0;
return -1;
}
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment