Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 7f9ec5593e04827249e7aeb466da06a98a0d7329 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?=E5=AD=99=E6=B5=A9=20and=20=E5=BC=A0=E6=B4=AA=E4=BA=AE=28?= |
| 3 | =?UTF-8?q?=E6=9C=9B=E5=88=9D=29?= <tony.sh and wangchu.zhl@alibaba-inc.com> |
| 4 | Date: Fri, 25 Aug 2017 12:37:25 +0200 |
| 5 | Subject: [PATCH] avformat/asfdec: Fix DoS due to lack of eof check |
| 6 | |
| 7 | Fixes: loop.asf |
| 8 | |
| 9 | Found-by: Xiaohei and Wangchu from Alibaba Security Team |
| 10 | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> |
| 11 | |
| 12 | CVE: CVE-2017-14057 |
| 13 | Upstream-Status: Backport |
| 14 | |
| 15 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
| 16 | --- |
| 17 | libavformat/asfdec_f.c | 6 ++++-- |
| 18 | 1 file changed, 4 insertions(+), 2 deletions(-) |
| 19 | |
| 20 | diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c |
| 21 | index be09a92..f3acbae 100644 |
| 22 | --- a/libavformat/asfdec_f.c |
| 23 | +++ b/libavformat/asfdec_f.c |
| 24 | @@ -749,13 +749,15 @@ static int asf_read_marker(AVFormatContext *s, int64_t size) |
| 25 | count = avio_rl32(pb); // markers count |
| 26 | avio_rl16(pb); // reserved 2 bytes |
| 27 | name_len = avio_rl16(pb); // name length |
| 28 | - for (i = 0; i < name_len; i++) |
| 29 | - avio_r8(pb); // skip the name |
| 30 | + avio_skip(pb, name_len); |
| 31 | |
| 32 | for (i = 0; i < count; i++) { |
| 33 | int64_t pres_time; |
| 34 | int name_len; |
| 35 | |
| 36 | + if (avio_feof(pb)) |
| 37 | + return AVERROR_INVALIDDATA; |
| 38 | + |
| 39 | avio_rl64(pb); // offset, 8 bytes |
| 40 | pres_time = avio_rl64(pb); // presentation time |
| 41 | pres_time -= asf->hdr.preroll * 10000; |
| 42 | -- |
| 43 | 2.1.0 |
| 44 | |