[FFmpeg-cvslog] avcodec/v210dec: disallow negative custom stride
Marton Balint
git at videolan.org
Tue Jun 21 00:35:47 EEST 2022
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Jun 12 00:13:27 2022 +0200| [571683696306f22d9519f62dcffb2164d49ee3c5] | committer: Marton Balint
avcodec/v210dec: disallow negative custom stride
Also make sure a big custom stride does not overflow size check.
Avoids segfaults.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=571683696306f22d9519f62dcffb2164d49ee3c5
---
libavcodec/v210dec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index c89440658f..e97f43a8e6 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -141,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
stride = aligned_width * 8 / 3;
}
- if (avpkt->size < stride * avctx->height) {
+ if (avpkt->size < (int64_t)stride * avctx->height) {
if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
stride = avpkt->size / avctx->height;
if (!s->stride_warning_shown)
@@ -190,7 +190,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
#define V210DEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
static const AVOption v210dec_options[] = {
{"custom_stride", "Custom V210 stride", offsetof(V210DecContext, custom_stride), AV_OPT_TYPE_INT,
- {.i64 = 0}, INT_MIN, INT_MAX, V210DEC_FLAGS},
+ {.i64 = 0}, 0, INT_MAX, V210DEC_FLAGS},
{NULL}
};
More information about the ffmpeg-cvslog
mailing list