summaryrefslogtreecommitdiff
path: root/libavformat/dsicin.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-04-23 19:44:08 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-09 13:54:52 +0200
commitd92939f984ccd28f361599c6f8ebe80f0c41a7fa (patch)
treeb5bec08ac7d78b0f97699e331b39259ce52d0d9c /libavformat/dsicin.c
parent8cacdaf8197222a04ce40c37b2f56c4516cb1a92 (diff)
downloadffmpeg-d92939f984ccd28f361599c6f8ebe80f0c41a7fa.tar.gz
avformat/dsicin: Check packet size for overflow
Fixes: signed integer overflow: 24672 + 2147483424 cannot be represented in type 'int' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_DSICIN_fuzzer-6731325979623424 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 9d1c47ec033d038e04578eaf0767c8983250d03d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/dsicin.c')
-rw-r--r--libavformat/dsicin.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/dsicin.c b/libavformat/dsicin.c
index bd4f3ad03a..a1ecd64939 100644
--- a/libavformat/dsicin.c
+++ b/libavformat/dsicin.c
@@ -166,7 +166,8 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
CinDemuxContext *cin = s->priv_data;
AVIOContext *pb = s->pb;
CinFrameHeader *hdr = &cin->frame_header;
- int rc, palette_type, pkt_size;
+ int rc, palette_type;
+ int64_t pkt_size;
int ret;
if (cin->audio_buffer_size == 0) {
@@ -182,7 +183,9 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
}
/* palette and video packet */
- pkt_size = (palette_type + 3) * hdr->pal_colors_count + hdr->video_frame_size;
+ pkt_size = (palette_type + 3LL) * hdr->pal_colors_count + hdr->video_frame_size;
+ if (pkt_size + 4 > INT_MAX)
+ return AVERROR_INVALIDDATA;
pkt_size = ffio_limit(pb, pkt_size);