[PATCH 1/2] avformat/wtvdec: ignore MPEG2VIDEO extradata when count is invalid
Fixes ticket #3522. Signed-off-by: Peter Ross <pross@xvid.org> --- libavformat/wtvdec.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 45e6b4a..bf27f29 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -635,7 +635,7 @@ static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code */ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ff_asf_guid mediatype, ff_asf_guid subtype, - ff_asf_guid formattype, int size) + ff_asf_guid formattype, uint64_t size) { WtvContext *wtv = s->priv_data; AVIOContext *pb = wtv->pb; @@ -693,16 +693,20 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, int consumed = parse_videoinfoheader2(s, st); avio_skip(pb, FFMAX(size - consumed, 0)); } else if (!ff_guidcmp(formattype, ff_format_mpeg2_video)) { - int consumed = parse_videoinfoheader2(s, st); - int count; - avio_skip(pb, 4); - count = avio_rl32(pb); - avio_skip(pb, 12); - if (count && ff_get_extradata(st->codec, pb, count) < 0) { - ff_free_stream(s, st); - return NULL; + uint64_t consumed = parse_videoinfoheader2(s, st); + if (size - consumed >= 20) { + uint32_t count; + consumed += 20; + avio_skip(pb, 4); + count = avio_rl32(pb); + count = FFMIN(count, size - consumed); + avio_skip(pb, 12); + if (count && ff_get_extradata(st->codec, pb, count) < 0) { + ff_free_stream(s, st); + return NULL; + } + consumed += count; } - consumed += 20 + count; avio_skip(pb, FFMAX(size - consumed, 0)); } else { if (ff_guidcmp(formattype, ff_format_none)) -- 1.8.3.2 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Signed-off-by: Peter Ross <pross@xvid.org> --- libavformat/wtvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index bf27f29..597a11f 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -562,7 +562,7 @@ static int parse_videoinfoheader2(AVFormatContext *s, AVStream *st) AVIOContext *pb = wtv->pb; avio_skip(pb, 72); // picture aspect ratio is unreliable - ff_get_bmp_header(pb, st, NULL); + st->codec->codec_tag = ff_get_bmp_header(pb, st, NULL); return 72 + 40; } -- 1.8.3.2 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Fri, Apr 04, 2014 at 10:07:47PM +1100, Peter Ross wrote:
Signed-off-by: Peter Ross <pross@xvid.org> --- libavformat/wtvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato
On Fri, Apr 04, 2014 at 10:07:36PM +1100, Peter Ross wrote:
Fixes ticket #3522.
Signed-off-by: Peter Ross <pross@xvid.org> --- libavformat/wtvdec.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle
participants (2)
-
Michael Niedermayer -
Peter Ross