[04/18] matroskadec: Verify realaudio codec parameters

Message ID 1379358389-64839-4-git-send-email-martin@martin.st
State Committed
Commit 569d18aa9dc989c37bb4d4b968026fe5afa6fff9
Headers show

Commit Message

Martin Storsjö Sept. 16, 2013, 7:06 p.m.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavformat/matroskadec.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Luca Barbato Sept. 16, 2013, 9:35 p.m. | #1
On 16/09/13 21:06, Martin Storsjö wrote:
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
>  libavformat/matroskadec.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 

Ok.

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index e8ef81f..dc32fd1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1622,6 +1622,10 @@  static int matroska_read_header(AVFormatContext *s)
             track->audio.sub_packet_h    = avio_rb16(&b);
             track->audio.frame_size      = avio_rb16(&b);
             track->audio.sub_packet_size = avio_rb16(&b);
+            if (flavor <= 0 || track->audio.coded_framesize <= 0 ||
+                track->audio.sub_packet_h <= 0 || track->audio.frame_size <= 0 ||
+                track->audio.sub_packet_size <= 0)
+                return AVERROR_INVALIDDATA;
             track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
             if (codec_id == AV_CODEC_ID_RA_288) {
                 st->codec->block_align = track->audio.coded_framesize;