[FFmpeg-cvslog] electronicarts: Check packet sizes before reading

Martin Storsjö git at videolan.org
Mon Sep 23 14:34:50 CEST 2013


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Fri Sep 20 12:26:45 2013 +0300| [f7e616959aff8706edccdae763c24c897c449f6f] | committer: Martin Storsjö

electronicarts: Check packet sizes before reading

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f7e616959aff8706edccdae763c24c897c449f6f
---

 libavformat/electronicarts.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index e764bd9..b0e0674 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -555,10 +555,16 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
             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;



More information about the ffmpeg-cvslog mailing list