diff mbox series

[FFmpeg-devel,4/4] avformat/r3d: Check samples before computing duration

Message ID 20210211211715.6234-4-michael@niedermayer.cc
State Accepted
Commit 7a2aa5dc2af6c4fc66aaedd341b0886fbc746f0d
Headers show
Series [FFmpeg-devel,1/4] avcodec/pnm_parser: Check av_image_get_buffer_size() for failure | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Feb. 11, 2021, 9:17 p.m. UTC
Fixes: signed integer overflow: -4611686024827895807 + -4611686016279904256 cannot be represented in type 'long'
Fixes: 30161/clusterfuzz-testcase-minimized-ffmpeg_dem_R3D_fuzzer-5694406713802752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/r3d.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paul B Mahol Feb. 11, 2021, 9:28 p.m. UTC | #1
lgtm
Michael Niedermayer Feb. 12, 2021, 9:57 a.m. UTC | #2
On Thu, Feb 11, 2021 at 10:28:36PM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 606ed010d6..9de0fb52c7 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -325,7 +325,8 @@  static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
 
     pkt->stream_index = 1;
     pkt->dts = dts;
-    if (st->codecpar->sample_rate)
+
+    if (st->codecpar->sample_rate && samples > 0)
         pkt->duration = av_rescale(samples, st->time_base.den, st->codecpar->sample_rate);
     av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %"PRId64" samples %d sample rate %d\n",
             pkt->dts, pkt->duration, samples, st->codecpar->sample_rate);