diff mbox series

[FFmpeg-devel,3/3] avformat/mov: disallow a zero sample size in trun atoms

Message ID 20220627200241.7102-3-cus@passwd.hu
State Accepted
Commit 03d81a044ad587ea83567f75dc36bc3d64278199
Headers show
Series [FFmpeg-devel,1/3] Revert "avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in avformat_find_stream_info()" | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Marton Balint June 27, 2022, 8:02 p.m. UTC
In order to not generate 0 sized packets or create a huge index table
needlessly.

Fixes: Timeout
Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304
Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Zhao Zhili June 28, 2022, 3:03 a.m. UTC | #1
> On Jun 28, 2022, at 4:02 AM, Marton Balint <cus@passwd.hu> wrote:
> 
> In order to not generate 0 sized packets or create a huge index table
> needlessly.
> 
> Fixes: Timeout
> Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304
> Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavformat/mov.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index c6fbe511c0..d7ef6ba6d6 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -5179,6 +5179,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>         distance++;
>         if (av_sat_add64(dts, sample_duration) != dts + (uint64_t)sample_duration)
>             return AVERROR_INVALIDDATA;
> +        if (!sample_size)
> +            return AVERROR_INVALIDDATA;
>         dts += sample_duration;
>         offset += sample_size;
>         sc->data_size += sample_size;

LGTM.

> -- 
> 2.35.3
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marton Balint July 6, 2022, 9:38 p.m. UTC | #2
On Tue, 28 Jun 2022, "zhilizhao(赵志立)" wrote:

>
>
>> On Jun 28, 2022, at 4:02 AM, Marton Balint <cus@passwd.hu> wrote:
>>
>> In order to not generate 0 sized packets or create a huge index table
>> needlessly.
>>
>> Fixes: Timeout
>> Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304
>> Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>> libavformat/mov.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index c6fbe511c0..d7ef6ba6d6 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -5179,6 +5179,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>>         distance++;
>>         if (av_sat_add64(dts, sample_duration) != dts + (uint64_t)sample_duration)
>>             return AVERROR_INVALIDDATA;
>> +        if (!sample_size)
>> +            return AVERROR_INVALIDDATA;
>>         dts += sample_duration;
>>         offset += sample_size;
>>         sc->data_size += sample_size;
>
> LGTM.

Thanks, applied the series.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c6fbe511c0..d7ef6ba6d6 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5179,6 +5179,8 @@  static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         distance++;
         if (av_sat_add64(dts, sample_duration) != dts + (uint64_t)sample_duration)
             return AVERROR_INVALIDDATA;
+        if (!sample_size)
+            return AVERROR_INVALIDDATA;
         dts += sample_duration;
         offset += sample_size;
         sc->data_size += sample_size;