aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mpegenc.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2009-06-17 19:04:02 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2009-06-17 19:04:02 +0000
commitf4ca612fbd9549e74dafa1c5bfb3e7b33e4b38e2 (patch)
treef3a07fd7f77c9554d1c1179b37ff414656103892 /libavformat/mpegenc.c
parentfa8c408b26fb5aa52d1e120d821710fe5bdd620e (diff)
downloadffmpeg-f4ca612fbd9549e74dafa1c5bfb3e7b33e4b38e2.tar.gz
Set restrictions on packet_size, as per ISO-11172 / H-222 specifications
(max packet size should fit in 13 bits as a kB value, so 1<<23, plus the header which is 10 bytes), and as per mpegenc.c internal assumptions (min packet size is 20 bytes). See "[PATCH] make packet_size in AVFormatContext unsigned" thread. Originally committed as revision 19215 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mpegenc.c')
-rw-r--r--libavformat/mpegenc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index b7bb69b91d..df4c9919a4 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -304,9 +304,14 @@ static int mpeg_mux_init(AVFormatContext *ctx)
(CONFIG_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer));
s->is_dvd = (CONFIG_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer);
- if(ctx->packet_size)
+ if(ctx->packet_size) {
+ if (ctx->packet_size < 20 || ctx->packet_size > (1 << 23) + 10) {
+ av_log(ctx, AV_LOG_ERROR, "Invalid packet size %d\n",
+ ctx->packet_size);
+ goto fail;
+ }
s->packet_size = ctx->packet_size;
- else
+ } else
s->packet_size = 2048;
s->vcd_padding_bytes_written = 0;