Commit c2e2b302 authored by Paul B Mahol's avatar Paul B Mahol

cafdec: fix parsing of chunks which may have unused data

Specification mentions 'strg', 'mark', 'regn', 'info', .. chunks
to have data section size larger than chunk's current meaningful
content in order to reserve room for additional data.
Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 3d6a246b
......@@ -225,7 +225,7 @@ static int read_header(AVFormatContext *s)
AVStream *st;
uint32_t tag = 0;
int found_data, ret;
int64_t size;
int64_t size, pos;
avio_skip(pb, 8); /* magic, version, file flags */
......@@ -254,6 +254,7 @@ static int read_header(AVFormatContext *s)
tag = avio_rb32(pb);
size = avio_rb64(pb);
pos = avio_tell(pb);
if (url_feof(pb))
break;
......@@ -296,9 +297,14 @@ static int read_header(AVFormatContext *s)
case MKBETAG('f','r','e','e'):
if (size < 0)
return AVERROR_INVALIDDATA;
avio_skip(pb, size);
break;
}
if (size > 0) {
if (pos + size < pos)
return AVERROR_INVALIDDATA;
avio_skip(pb, FFMAX(0, pos + size - avio_tell(pb)));
}
}
if (!found_data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment