1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avformat/rtpdec: fix integer overflow in start_time_realtime calculation

I encountered this problem with NTP timestamps that are extremely old,
like from January, 1990.

Although RFC3550 suggests that the timestamps in the RTCP packets use
the actual wallclock, some implementations use other clocks, such as
the CLOCK_MONOTONIC on linux.

I'm my case, I'm dealing with packets from mediasoup.

Without this patch, start_time_realtime shows up in the distance future
instead of around Jan 1900.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Jonathan Baudanza 2024-09-04 17:06:15 +09:00 committed by Anton Khirnov
parent 660e7e6a0e
commit 6b3f9c2e92

View File

@ -2320,7 +2320,7 @@ redo:
} }
// Make real NTP start time available in AVFormatContext // Make real NTP start time available in AVFormatContext
if (s->start_time_realtime == AV_NOPTS_VALUE) { if (s->start_time_realtime == AV_NOPTS_VALUE) {
s->start_time_realtime = av_rescale (rtpctx->first_rtcp_ntp_time - (NTP_OFFSET << 32), 1000000, 1LL << 32); s->start_time_realtime = av_rescale (rtpctx->first_rtcp_ntp_time, 1000000, 1LL << 32) - NTP_OFFSET_US;
if (rtpctx->st) { if (rtpctx->st) {
s->start_time_realtime -= s->start_time_realtime -=
av_rescale_q (rtpctx->rtcp_ts_offset, rtpctx->st->time_base, AV_TIME_BASE_Q); av_rescale_q (rtpctx->rtcp_ts_offset, rtpctx->st->time_base, AV_TIME_BASE_Q);