From: James Almer Date: Thu, 28 Sep 2017 03:09:20 +0000 (-0300) Subject: Merge commit 'b446f0e98f85e2e931b476e52b319f1c49244660' X-Git-Tag: n3.5-dev~172 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/d99c3af7072d0011c4f2cbedb2f624e6b616cfc0 Merge commit 'b446f0e98f85e2e931b476e52b319f1c49244660' * commit 'b446f0e98f85e2e931b476e52b319f1c49244660': mov: Do not try to parse multiple stsd for the same track See 8b43ee4054af799e388d380b379a13a60849c1b5 Merged-by: James Almer --- d99c3af7072d0011c4f2cbedb2f624e6b616cfc0 diff --cc libavformat/mov.c index 19cda14,5c9f85c..ede9cda --- a/libavformat/mov.c +++ b/libavformat/mov.c @@@ -2365,24 -1911,23 +2365,26 @@@ static int mov_read_stsd(MOVContext *c avio_rb24(pb); /* flags */ entries = avio_rb32(pb); + if (entries <= 0) { + av_log(c->fc, AV_LOG_ERROR, "invalid STSD entries %d\n", entries); + return AVERROR_INVALIDDATA; + } + if (sc->extradata) { - av_log(c->fc, AV_LOG_ERROR, "Duplicate STSD\n"); + av_log(c->fc, AV_LOG_ERROR, + "Duplicate stsd found in this track.\n"); return AVERROR_INVALIDDATA; } + /* Prepare space for hosting multiple extradata. */ sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata)); - if (!sc->extradata) - return AVERROR(ENOMEM); - - sc->stsd_count = entries; - sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata_size)); - if (!sc->extradata_size) - return AVERROR(ENOMEM); + sc->extradata_size = av_mallocz_array(entries, sizeof(*sc->extradata_size)); + if (!sc->extradata_size || !sc->extradata) { + ret = AVERROR(ENOMEM); + goto fail; + } - ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count); + ret = ff_mov_read_stsd_entries(c, pb, entries); if (ret < 0) return ret;