avformat/mov: Add check for per-sample IV size.

Found by Chrome's ClusterFuzz: http://crbug.com/849062.

Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Jacob Trimble 2018-06-12 14:26:20 -07:00 committed by Michael Niedermayer
parent 9461e7d3a5
commit 4aba45ca1f
1 changed files with 7 additions and 2 deletions

View File

@ -6273,8 +6273,13 @@ static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
sc->cenc.per_sample_iv_size = avio_r8(pb); sc->cenc.per_sample_iv_size = avio_r8(pb);
if (sc->cenc.per_sample_iv_size != 0 && sc->cenc.per_sample_iv_size != 8 &&
sc->cenc.per_sample_iv_size != 16) {
av_log(c->fc, AV_LOG_ERROR, "invalid per-sample IV size value\n");
return AVERROR_INVALIDDATA;
}
if (avio_read(pb, sc->cenc.default_encrypted_sample->key_id, 16) != 16) { if (avio_read(pb, sc->cenc.default_encrypted_sample->key_id, 16) != 16) {
av_log(c->fc, AV_LOG_ERROR, "failed to read the default key ID"); av_log(c->fc, AV_LOG_ERROR, "failed to read the default key ID\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -6286,7 +6291,7 @@ static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
} }
if (avio_read(pb, sc->cenc.default_encrypted_sample->iv, iv_size) != iv_size) { if (avio_read(pb, sc->cenc.default_encrypted_sample->iv, iv_size) != iv_size) {
av_log(c->fc, AV_LOG_ERROR, "failed to read the default IV"); av_log(c->fc, AV_LOG_ERROR, "failed to read the default IV\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
} }