From: Matt Wolenetz Date: Wed, 14 Dec 2016 23:27:49 +0000 (-0800) Subject: lavf/mov.c: Avoid heap allocation wraps in mov_read_{senc,saiz}() X-Git-Tag: android-x86-7.1-r1~2152 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=36aba43bd5fae8595dd9a566fbcfbbea63f0fca3;p=android-x86%2Fexternal-ffmpeg.git lavf/mov.c: Avoid heap allocation wraps in mov_read_{senc,saiz}() Core of patch is from paul@paulmehta.com Reference https://crbug.com/643952 (senc,saiz portions) Signed-off-by: Matt Wolenetz Signed-off-by: Michael Niedermayer --- diff --git a/libavformat/mov.c b/libavformat/mov.c index f804614a50..b5181775e7 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4968,8 +4968,8 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_rb32(pb); /* entries */ - if (atom.size < 8) { - av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" too small\n", atom.size); + if (atom.size < 8 || atom.size > FFMIN(INT_MAX, SIZE_MAX)) { + av_log(c->fc, AV_LOG_ERROR, "senc atom size %"PRId64" invalid\n", atom.size); return AVERROR_INVALIDDATA; } @@ -5037,6 +5037,11 @@ static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } + if (atom.size > FFMIN(INT_MAX, SIZE_MAX)) { + av_log(c->fc, AV_LOG_ERROR, "saiz atom auxiliary_info_sizes size %"PRId64" invalid\n", atom.size); + return AVERROR_INVALIDDATA; + } + /* save the auxiliary info sizes as is */ data_size = atom.size - atom_header_size;