[FFmpeg-devel] msrle_decode_init: check frame dimensions

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

Details

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

Commit Message

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

Comments

Michael Niedermayer June 13, 2018, 12:31 p.m.
On Tue, Jun 12, 2018 at 12:27:20AM +0000, Xiao Yang wrote:
> ---
>  libavcodec/msrle.c |    7 +++++++
>  1 file changed, 7 insertions(+)

breaks files with odd dimension, which decode fine before this patch


[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
index adb55b1..cd952a8 100644
--- a/libavcodec/msrle.c
+++ b/libavcodec/msrle.c
@@ -71,6 +71,13 @@  static av_cold int msrle_decode_init(AVCodecContext *avctx)
         return AVERROR_INVALIDDATA;
     }
 
+    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);