[FFmpeg-devel] cinvideo_decode_init: check frame dimensions

Submitted by Xiao Yang on June 12, 2018, 12:43 a.m.

Details

Message ID SIXPR01MB05606154224CFCC86151EB4BAD7F0@SIXPR01MB0560.apcprd01.prod.exchangelabs.com
State New
Headers show

Commit Message

Xiao Yang June 12, 2018, 12:43 a.m.
---
 libavcodec/dsicinvideo.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Michael Niedermayer June 13, 2018, 2:29 p.m.
On Tue, Jun 12, 2018 at 12:43:24AM +0000, Xiao Yang wrote:
> ---
>  libavcodec/dsicinvideo.c |    7 +++++++
>  1 file changed, 7 insertions(+)

please provide a reproduable testcase that shows the problem this fixes

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c
index aa08041..d0f79d9 100644
--- a/libavcodec/dsicinvideo.c
+++ b/libavcodec/dsicinvideo.c
@@ -73,6 +73,13 @@  static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
     cin->avctx = avctx;
     avctx->pix_fmt = AV_PIX_FMT_PAL8;
 
+    if (!avctx->width || !avctx->height ||
+        (avctx->width & 1) || (avctx->height & 1)) {
+        av_log(avctx, AV_LOG_ERROR, "Invalid video dimensions: %dx%d\n",
+               avctx->width, avctx->height);
+        return AVERROR(EINVAL);
+    }
+
     cin->frame = av_frame_alloc();
     if (!cin->frame)
         return AVERROR(ENOMEM);