diff mbox series

[FFmpeg-devel,3/4] avformat/dcstr: Check sample rate

Message ID 20210303094904.4221-3-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avcodec/jpegls: Check A[Q] for overflow in ff_jpegls_update_state_regular()
Related show

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 March 3, 2021, 9:49 a.m. UTC
Fixes: signed integer overflow: -1300248894420254720 * 16 cannot be represented in type 'long'
Fixes: 30879/clusterfuzz-testcase-minimized-ffmpeg_dem_DCSTR_fuzzer-5094464215449600

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

Comments

Paul B Mahol March 3, 2021, 11:18 a.m. UTC | #1
Check also for == 0 case

On Wed, Mar 3, 2021 at 10:50 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> Fixes: signed integer overflow: -1300248894420254720 * 16 cannot be
> represented in type 'long'
> Fixes:
> 30879/clusterfuzz-testcase-minimized-ffmpeg_dem_DCSTR_fuzzer-5094464215449600
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> <https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by>:
> Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/dcstr.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c
> index 9041a86539..1233baaf7e 100644
> --- a/libavformat/dcstr.c
> +++ b/libavformat/dcstr.c
> @@ -43,6 +43,8 @@ static int dcstr_read_header(AVFormatContext *s)
>      st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->channels    = avio_rl32(s->pb);
>      st->codecpar->sample_rate = avio_rl32(s->pb);
> +    if (st->codecpar->sample_rate < 0)
> +        return AVERROR_INVALIDDATA;
>      codec                  = avio_rl32(s->pb);
>      align                  = avio_rl32(s->pb);
>      avio_skip(s->pb, 4);
> --
> 2.17.1
>
> _______________________________________________
> 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".
Michael Niedermayer March 3, 2021, 3:28 p.m. UTC | #2
On Wed, Mar 03, 2021 at 12:18:32PM +0100, Paul B Mahol wrote:
> Check also for == 0 case

ok, will apply with that change

Thanks!

[...]
diff mbox series

Patch

diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c
index 9041a86539..1233baaf7e 100644
--- a/libavformat/dcstr.c
+++ b/libavformat/dcstr.c
@@ -43,6 +43,8 @@  static int dcstr_read_header(AVFormatContext *s)
     st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
     st->codecpar->channels    = avio_rl32(s->pb);
     st->codecpar->sample_rate = avio_rl32(s->pb);
+    if (st->codecpar->sample_rate < 0)
+        return AVERROR_INVALIDDATA;
     codec                  = avio_rl32(s->pb);
     align                  = avio_rl32(s->pb);
     avio_skip(s->pb, 4);