From 3ca14aa5964ea5d11f7a15f9fff17924d6096d44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Thu, 19 Sep 2013 16:57:47 +0300
Subject: rl2: Avoid a division by zero
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
---
 libavformat/rl2.c | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'libavformat')

diff --git a/libavformat/rl2.c b/libavformat/rl2.c
index ac0532f1c9..ab33aabccc 100644
--- a/libavformat/rl2.c
+++ b/libavformat/rl2.c
@@ -107,6 +107,10 @@ static av_cold int rl2_read_header(AVFormatContext *s)
     rate = avio_rl16(pb);
     channels = avio_rl16(pb);
     def_sound_size = avio_rl16(pb);
+    if (!channels || channels > 42) {
+        av_log(s, AV_LOG_ERROR, "Invalid number of channels: %d\n", channels);
+        return AVERROR_INVALIDDATA;
+    }
 
     /** setup video stream */
     st = avformat_new_stream(s, NULL);
-- 
cgit v1.2.3