Message ID | 20220918171410.31835-10-michael@niedermayer.cc |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,01/13] avformat/flvdec: Use 64bit for sum_flv_tag_size | expand |
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 |
Quoting Michael Niedermayer (2022-09-18 19:14:07) > Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' > Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > --- > libavformat/vividas.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavformat/vividas.c b/libavformat/vividas.c > index e9954f73ed0..22f61db7576 100644 > --- a/libavformat/vividas.c > +++ b/libavformat/vividas.c > @@ -643,7 +643,9 @@ static int viv_read_packet(AVFormatContext *s, > > if (viv->current_audio_subpacket < viv->n_audio_subpackets) { > AVStream *astream; > - int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start; > + int64_t size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - (int64_t)viv->audio_subpackets[viv->current_audio_subpacket].start; > + if (size < 0 || size != (int)size) > + return AVERROR_INVALIDDATA; These values should be checked in the loop where they are set.
On Thu, Sep 22, 2022 at 03:18:20PM +0200, Anton Khirnov wrote: > Quoting Michael Niedermayer (2022-09-18 19:14:07) > > Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' > > Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 > > > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > --- > > libavformat/vividas.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/vividas.c b/libavformat/vividas.c > > index e9954f73ed0..22f61db7576 100644 > > --- a/libavformat/vividas.c > > +++ b/libavformat/vividas.c > > @@ -643,7 +643,9 @@ static int viv_read_packet(AVFormatContext *s, > > > > if (viv->current_audio_subpacket < viv->n_audio_subpackets) { > > AVStream *astream; > > - int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start; > > + int64_t size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - (int64_t)viv->audio_subpackets[viv->current_audio_subpacket].start; > > + if (size < 0 || size != (int)size) > > + return AVERROR_INVALIDDATA; > > These values should be checked in the loop where they are set. ok but then we fail before the actual problem is encountered i will send a patch doing that thx [...]
diff --git a/libavformat/vividas.c b/libavformat/vividas.c index e9954f73ed0..22f61db7576 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -643,7 +643,9 @@ static int viv_read_packet(AVFormatContext *s, if (viv->current_audio_subpacket < viv->n_audio_subpackets) { AVStream *astream; - int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start; + int64_t size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - (int64_t)viv->audio_subpackets[viv->current_audio_subpacket].start; + if (size < 0 || size != (int)size) + return AVERROR_INVALIDDATA; pb = viv->sb_pb; ret = av_get_packet(pb, pkt, size);
Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vividas.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)