diff options
author | Martin Storsjö <martin@martin.st> | 2013-09-20 12:26:45 +0300 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-10-04 03:26:30 +0200 |
commit | 8bd27a167b6e22e7da964df1638c493d51a9663b (patch) | |
tree | ffc782254f06189ecc5b373fac5107faf1512ea6 | |
parent | 17e7edf75b451edd7dde4816c3225fd1557517c7 (diff) | |
download | ffmpeg-8bd27a167b6e22e7da964df1638c493d51a9663b.tar.gz |
electronicarts: Check packet sizes before reading
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit f7e616959aff8706edccdae763c24c897c449f6f)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | libavformat/electronicarts.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index ae2fda079f..ebb4c124dd 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -525,10 +525,16 @@ static int ea_read_packet(AVFormatContext *s, case AV_CODEC_ID_ADPCM_EA_R1: case AV_CODEC_ID_ADPCM_EA_R2: case AV_CODEC_ID_ADPCM_IMA_EA_EACS: - pkt->duration = AV_RL32(pkt->data); - break; case AV_CODEC_ID_ADPCM_EA_R3: - pkt->duration = AV_RB32(pkt->data); + if (pkt->size < 4) { + av_log(s, AV_LOG_ERROR, "Packet is too short\n"); + av_free_packet(pkt); + return AVERROR_INVALIDDATA; + } + if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3) + pkt->duration = AV_RB32(pkt->data); + else + pkt->duration = AV_RL32(pkt->data); break; case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: pkt->duration = ret * 2 / ea->num_channels; |