Commit 69b876b3 authored by Olivier Crête's avatar Olivier Crête

agent: Make sure there is no integer overflow if the timeout is now

Make sure that if the timeout is now, no negative number is passed as
an unsigned
parent a3abccdd
...@@ -1217,11 +1217,16 @@ adjust_tcp_clock (NiceAgent *agent, Stream *stream, Component *component) ...@@ -1217,11 +1217,16 @@ adjust_tcp_clock (NiceAgent *agent, Stream *stream, Component *component)
component->tcp_clock = NULL; component->tcp_clock = NULL;
#endif #endif
} }
if (!component->tcp_clock) if (!component->tcp_clock) {
component->tcp_clock = agent_timeout_add_with_context (agent, long interval = timeout - (g_get_monotonic_time () / 1000);
timeout - (g_get_monotonic_time () / 1000),
/* Prevent integer overflows */
if (interval < 0 || interval > G_MAXINT)
interval = 0;
component->tcp_clock = agent_timeout_add_with_context (agent, interval,
notify_pseudo_tcp_socket_clock, component); notify_pseudo_tcp_socket_clock, component);
} }
}
} else { } else {
nice_debug ("Agent %p: component %d pseudo-TCP socket should be " nice_debug ("Agent %p: component %d pseudo-TCP socket should be "
"destroyed. Calling priv_pseudo_tcp_error().", "destroyed. Calling priv_pseudo_tcp_error().",
......
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