[FFmpeg-devel] [PATCH 4/8] ffmdec: don't set extradata_size without allocating extradata

2015-03-08 Thread Andreas Cadhalpun

Hi,

attached patch fixes crashes with ffm files containing an extradata_size 
setting, but without extradata.


Such files are created by the ffm muxer, e.g. with for the asv1 codec.

Best regards,
Andreas
>From b3da247975db1bc0dd86805f2830aa0b718fd355 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun 
Date: Sun, 8 Mar 2015 23:24:40 +0100
Subject: [PATCH 4/8] ffmdec: don't set extradata_size without allocating
 extradata

When extradata_size is not 0, but extradata is NULL, code trying to use
extradata crashes.

If there is any extradata, extradata_size is set in ff_get_extradata.

Signed-off-by: Andreas Cadhalpun 
---
 libavformat/ffmdec.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 2459691..35e4c03 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -260,7 +260,7 @@ static int ffm2_read_header(AVFormatContext *s)
 AVStream *st;
 AVIOContext *pb = s->pb;
 AVCodecContext *codec = NULL;
-int ret;
+int ret, old_extradata_size;
 int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
 AVCodec *enc;
 char *buffer;
@@ -411,6 +411,7 @@ static int ffm2_read_header(AVFormatContext *s)
 ret = AVERROR(EINVAL);
 goto fail;
 }
+old_extradata_size = codec->extradata_size;
 buffer = av_malloc(size);
 if (!buffer) {
 ret = AVERROR(ENOMEM);
@@ -418,6 +419,11 @@ static int ffm2_read_header(AVFormatContext *s)
 }
 avio_get_str(pb, INT_MAX, buffer, size);
 av_set_options_string(codec, buffer, "=", ",");
+if (codec->extradata_size != old_extradata_size) {
+av_log(s, AV_LOG_WARNING, "ignoring extradata_size=%d in S2VI chunk\n",
+   codec->extradata_size);
+codec->extradata_size = old_extradata_size;
+}
 if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0)
 goto fail;
 break;
@@ -426,6 +432,7 @@ static int ffm2_read_header(AVFormatContext *s)
 ret = AVERROR(EINVAL);
 goto fail;
 }
+old_extradata_size = codec->extradata_size;
 buffer = av_malloc(size);
 if (!buffer) {
 ret = AVERROR(ENOMEM);
@@ -433,6 +440,11 @@ static int ffm2_read_header(AVFormatContext *s)
 }
 avio_get_str(pb, INT_MAX, buffer, size);
 av_set_options_string(codec, buffer, "=", ",");
+if (codec->extradata_size != old_extradata_size) {
+av_log(s, AV_LOG_WARNING, "ignoring extradata_size=%d in S2AU chunk\n",
+   codec->extradata_size);
+codec->extradata_size = old_extradata_size;
+}
 ffm_append_recommended_configuration(st, &buffer);
 break;
 }
-- 
2.1.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/8] ffmdec: don't set extradata_size without allocating extradata

2015-03-08 Thread Michael Niedermayer
On Mon, Mar 09, 2015 at 12:03:54AM +0100, Andreas Cadhalpun wrote:
> Hi,
> 
> attached patch fixes crashes with ffm files containing an
> extradata_size setting, but without extradata.
> 
> Such files are created by the ffm muxer, e.g. with for the asv1 codec.
> 
> Best regards,
> Andreas

>  ffmdec.c |   14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> beff822dbd6683a15edfc42702af8955475b0172  
> 0004-ffmdec-don-t-set-extradata_size-without-allocating-e.patch
> From b3da247975db1bc0dd86805f2830aa0b718fd355 Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun 
> Date: Sun, 8 Mar 2015 23:24:40 +0100
> Subject: [PATCH 4/8] ffmdec: don't set extradata_size without allocating
>  extradata
> 
> When extradata_size is not 0, but extradata is NULL, code trying to use
> extradata crashes.
> 
> If there is any extradata, extradata_size is set in ff_get_extradata.

ive posted a patch that removes the extradata_size field from the
AVOption table, i think thats better if it works

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel