[FFmpeg-devel] [PATCH] avcodec/jpeg2000dec: Ensure calculation of buf_size cannot overflow.

etemesicaleb at gmail.com etemesicaleb at gmail.com
Fri Apr 28 07:42:48 EEST 2023


From: caleb <etemesicaleb at gmail.com>

---
 libavcodec/jpeg2000htdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c
index 51cd96e0f1..d77293ddd8 100644
--- a/libavcodec/jpeg2000htdec.c
+++ b/libavcodec/jpeg2000htdec.c
@@ -595,7 +595,7 @@ static int jpeg2000_decode_ht_cleanup_segment(const Jpeg2000DecoderContext *s,
     const uint16_t quad_width  = ff_jpeg2000_ceildivpow2(width, 1);
     const uint16_t quad_height = ff_jpeg2000_ceildivpow2(height, 1);
 
-    size_t buf_size = 4 * quad_width * quad_height;
+    size_t buf_size = 4UL * quad_width * quad_height;
 
     uint8_t *sigma_n = av_calloc(buf_size, sizeof(uint8_t));
     uint8_t *E       = av_calloc(buf_size, sizeof(uint8_t));
-- 
2.39.2



More information about the ffmpeg-devel mailing list