Commit a0e6e9a4c6 for ffmpeg
commit a0e6e9a4c6744d561a30ec8dff61e6daa21b363f
Author: marcos ashton <marcosashiglesias@gmail.com>
Date: Tue Dec 1 15:27:59 2026 +0000
avcodec/decode: compare each crop field with the frame size in apply_cropping()
It had the same wrapping check as av_frame_apply_cropping(), so a crop_right or crop_bottom above INT_MAX from a decoder got past the warning.
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 4f40b3677e..a7d20af5ec 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -771,10 +771,10 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke
static int apply_cropping(AVCodecContext *avctx, AVFrame *frame)
{
/* make sure we are noisy about decoders returning invalid cropping data */
- if (frame->crop_left >= INT_MAX - frame->crop_right ||
- frame->crop_top >= INT_MAX - frame->crop_bottom ||
- (frame->crop_left + frame->crop_right) >= frame->width ||
- (frame->crop_top + frame->crop_bottom) >= frame->height) {
+ if (frame->crop_right >= frame->width ||
+ frame->crop_left >= frame->width - frame->crop_right ||
+ frame->crop_bottom >= frame->height ||
+ frame->crop_top >= frame->height - frame->crop_bottom) {
av_log(avctx, AV_LOG_WARNING,
"Invalid cropping information set by a decoder: "
"%zu/%zu/%zu/%zu (frame size %dx%d). "