[FFmpeg-devel] [PATCH] avcodec/dpx: check for possible buffer overreads

Paul B Mahol onemda at gmail.com
Fri Feb 12 01:00:17 EET 2021


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/dpx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 5372e3d586..68a2762017 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -606,6 +606,9 @@ static int decode_frame(AVCodecContext *avctx,
 
     ff_set_sar(avctx, avctx->sample_aspect_ratio);
 
+    if (buf_size - offset < (((uint64_t)elements * avctx->width * avctx->height * bits_per_color) >> 3))
+        return AVERROR_INVALIDDATA;
+
     if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
         return ret;
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list