[FFmpeg-devel] cinepak_decode_init: check frame dimensions

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

Details

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

Commit Message

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

Comments

Michael Niedermayer June 13, 2018, 1:06 a.m.
Hi

first please make sure you are subscribed to ffmpeg-devel if you want to
submit patches. submited patches are discussed on the ffmpeg-devel
mailing list almost always. People rarely think of CC-ing the author

then 2nd you should make sure you confirm both the bug you
are trying to fix as well as the fix with ffmpeg git master

is ffmpeg git master really affected by any of the bugs you are trying to fix?

also it is neccessary for you to understand the format you
are changing
and run tests to confirm that you are not breaking something.

The changes you are posting which i looked at so far are basically wrong.

we have cinepak files with odd resolutions even in the fate tests for example

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index 9b00774..3713ec0 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -430,6 +430,13 @@  static av_cold int cinepak_decode_init(AVCodecContext *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);
+    }
+
     s->frame = av_frame_alloc();
     if (!s->frame)
         return AVERROR(ENOMEM);