]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_rtp_asterisk: Fix dtls timer issues causing FRACKs and SEGVs
authorGeorge Joseph <gjoseph@sangoma.com>
Mon, 16 Sep 2024 21:17:28 +0000 (15:17 -0600)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 14 Nov 2024 20:01:34 +0000 (20:01 +0000)
commit2f3b10d1b235fc3fca9d974eca1c75033bfe15e1
tree250bf341032291c26b84b39001241b3cc5da76ac
parent8fe0e55d961d48e5abb5b2db8fe13b7828b2318e
res_rtp_asterisk: Fix dtls timer issues causing FRACKs and SEGVs

In dtls_srtp_handle_timeout(), when DTLSv1_get_timeout() returned
success but with a timeout of 0, we were stopping the timer and
decrementing the refcount on instance but not resetting the
timeout_timer to -1.  When dtls_srtp_stop_timeout_timer()
was later called, it was atempting to stop a stale timer and could
decrement the refcount on instance again which would then cause
the instance destructor to run early.  This would result in either
a FRACK or a SEGV when ast_rtp_stop(0 was called.

According to the OpenSSL docs, we shouldn't have been stopping the
timer when DTLSv1_get_timeout() returned success and the new timeout
was 0 anyway.  We should have been calling DTLSv1_handle_timeout()
again immediately so we now reschedule the timer callback for
1ms (almost immediately).

Additionally, instead of scheduling the timer callback at a fixed
interval returned by the initial call to DTLSv1_get_timeout()
(usually 999 ms), we now reschedule the next callback based on
the last call to DTLSv1_get_timeout().

Resolves: #487
(cherry picked from commit 7db8ae296c8b897d4c0dcaf5185cd8e574fb1084)
res/res_rtp_asterisk.c