diff mbox series

[FFmpeg-devel,1/4] avformat/mvdec: Check sample rate in parse_audio_var()

Message ID 20210428150636.28396-1-michael@niedermayer.cc
State Accepted
Commit 0ff60249a57cba00ab679ca6190a802cc0c7b9c7
Headers show
Series [FFmpeg-devel,1/4] avformat/mvdec: Check sample rate in parse_audio_var()
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 April 28, 2021, 3:06 p.m. UTC
Fixes: signed integer overflow: -635424002382840000 * 16 cannot be represented in type 'long'
Fixes: 33612/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5704741108711424

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

Comments

Peter Ross April 28, 2021, 10:50 p.m. UTC | #1
On Wed, Apr 28, 2021 at 05:06:33PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -635424002382840000 * 16 cannot be represented in type 'long'
> Fixes: 33612/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5704741108711424
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/mvdec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
> index 2f72f9eb4f..b1450e08da 100644
> --- a/libavformat/mvdec.c
> +++ b/libavformat/mvdec.c
> @@ -157,6 +157,8 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st,
>          return set_channels(avctx, st, var_read_int(pb, size));
>      } else if (!strcmp(name, "SAMPLE_RATE")) {
>          st->codecpar->sample_rate = var_read_int(pb, size);
> +        if (st->codecpar->sample_rate <= 0)
> +            return AVERROR_INVALIDDATA;
>          avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
>      } else if (!strcmp(name, "SAMPLE_WIDTH")) {
>          uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;
> -- 
> 2.17.1

please apply

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer May 4, 2021, 12:29 p.m. UTC | #2
On Thu, Apr 29, 2021 at 08:50:35AM +1000, Peter Ross wrote:
> On Wed, Apr 28, 2021 at 05:06:33PM +0200, Michael Niedermayer wrote:
> > Fixes: signed integer overflow: -635424002382840000 * 16 cannot be represented in type 'long'
> > Fixes: 33612/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5704741108711424
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/mvdec.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
> > index 2f72f9eb4f..b1450e08da 100644
> > --- a/libavformat/mvdec.c
> > +++ b/libavformat/mvdec.c
> > @@ -157,6 +157,8 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st,
> >          return set_channels(avctx, st, var_read_int(pb, size));
> >      } else if (!strcmp(name, "SAMPLE_RATE")) {
> >          st->codecpar->sample_rate = var_read_int(pb, size);
> > +        if (st->codecpar->sample_rate <= 0)
> > +            return AVERROR_INVALIDDATA;
> >          avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
> >      } else if (!strcmp(name, "SAMPLE_WIDTH")) {
> >          uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;
> > -- 
> > 2.17.1
> 
> please apply

will do

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index 2f72f9eb4f..b1450e08da 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -157,6 +157,8 @@  static int parse_audio_var(AVFormatContext *avctx, AVStream *st,
         return set_channels(avctx, st, var_read_int(pb, size));
     } else if (!strcmp(name, "SAMPLE_RATE")) {
         st->codecpar->sample_rate = var_read_int(pb, size);
+        if (st->codecpar->sample_rate <= 0)
+            return AVERROR_INVALIDDATA;
         avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
     } else if (!strcmp(name, "SAMPLE_WIDTH")) {
         uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;