avformat/asfdec: Fix DoS due to lack of eof check

Fixes: loop.asf

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/269/head
孙浩 and 张洪亮(望初) 7 years ago committed by Michael Niedermayer
parent 7ec414892d
commit 7f9ec5593e
  1. 6
      libavformat/asfdec_f.c

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

Loading…
Cancel
Save