diff mbox

[FFmpeg-devel] avformat/asfdec: Fix DoS due to lack of eof check

Message ID 20170825103725.11463-1-michael@niedermayer.cc
State Accepted
Commit 7f9ec5593e04827249e7aeb466da06a98a0d7329
Headers show

Commit Message

Michael Niedermayer Aug. 25, 2017, 10:37 a.m. UTC
From: "wangchu.zhl@alibaba-inc.com" <wangchu.zhl@alibaba-inc.com>

Fixes: loop.asf

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/asfdec_f.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Aug. 27, 2017, 5:14 p.m. UTC | #1
On Fri, Aug 25, 2017 at 12:37:25PM +0200, Michael Niedermayer wrote:
> From: "wangchu.zhl@alibaba-inc.com" <wangchu.zhl@alibaba-inc.com>
> 
> Fixes: loop.asf
> 
> Found-by: Xiaohei and Wangchu from Alibaba Security Team
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/asfdec_f.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

applied

[...]
diff mbox

Patch

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index be09a92bd1..f3acbae280 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -749,13 +749,15 @@  static int asf_read_marker(AVFormatContext *s, int64_t size)
     count = avio_rl32(pb);    // markers count
     avio_rl16(pb);            // reserved 2 bytes
     name_len = avio_rl16(pb); // name length
-    for (i = 0; i < name_len; i++)
-        avio_r8(pb); // skip the name
+    avio_skip(pb, name_len);
 
     for (i = 0; i < count; i++) {
         int64_t pres_time;
         int name_len;
 
+        if (avio_feof(pb))
+            return AVERROR_INVALIDDATA;
+
         avio_rl64(pb);             // offset, 8 bytes
         pres_time = avio_rl64(pb); // presentation time
         pres_time -= asf->hdr.preroll * 10000;