Commit 4ed2f60e1b for ffmpeg
commit 4ed2f60e1b30eeaa97535f60d857d2b613cbff76
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 15 04:17:31 2026 +0200
avcodec/flacenc: clamp the minimum LPC prediction order to 1
This is not a security issue.
Fixes: Qzx1V8a6y8DL
Fixes: swarm-Out-of-bounds-reads-on-coefs-shift-bits-when-min_prediction_order-is-0-0468ca
Found-by: zhang xingxing <2388969553@qq.com>
The report suggested ensuring min_order >= 1.
Out of array write Replicated through UnModified FFmpeg with ASAN
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index ead2c55f10..8d1c76870e 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -401,6 +401,11 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
s->options.max_prediction_order, MAX_FIXED_ORDER);
s->options.max_prediction_order = MAX_FIXED_ORDER;
}
+ } else if (s->options.min_prediction_order < MIN_LPC_ORDER) {
+ av_log(avctx, AV_LOG_WARNING,
+ "invalid min prediction order %d, clamped to %d\n",
+ s->options.min_prediction_order, MIN_LPC_ORDER);
+ s->options.min_prediction_order = MIN_LPC_ORDER;
}
if (s->options.max_prediction_order < s->options.min_prediction_order) {