Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-09-15 08:46:55 +0400
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-09-15 08:46:55 +0400
commit82eac2f3216534c065c5023e5599720bd17bed26 (patch)
tree6dc8782bb10b0d830e90f96fbf3d02e0baaffbc2 /libavcodec/utils.c
parent4faf628f2015b7c04510d39a99a2c52f11b765f3 (diff)
Check avctx width/height more thoroughly (e.g. all values 0 except width would
have been accepted before). Also do not fail if they are invalid but instead override them to 0. This allows decoding e.g. MPEG video when only the container values are corrupted. For encoding a value of 0,0 of course makes no sense, but was allowed through before and will be caught by an extra check in the encode function. Originally committed as revision 25124 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e12b677a93..543c1bdab5 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -485,10 +485,15 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
else if(avctx->width && avctx->height)
avcodec_set_dimensions(avctx, avctx->width, avctx->height);
+ if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
+ && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
+ || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
+ av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
+ avcodec_set_dimensions(avctx, 0, 0);
+ }
+
#define SANE_NB_CHANNELS 128U
- if (((avctx->coded_width || avctx->coded_height)
- && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
- || avctx->channels > SANE_NB_CHANNELS) {
+ if (avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
}