PR #26086 opened by fuzzyrichie URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26086 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26086.patch
Account for the 4-byte multipart part id when validating each chunk header and its compressed data size. This prevents data_size from allowing the compressed data window to extend past the packet buffer in both scanline and tile paths. >From f6849f98b4190473cfe97ecd9912349193587db9 Mon Sep 17 00:00:00 2001 From: Richard Desmarais <[email protected]> Date: Sun, 15 Nov 2026 17:23:00 -0500 Subject: [PATCH] exr: Fix multipart block bounds accounting for part id --- libavcodec/exr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index a61ba3b593a..8a82baf9bb8 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1264,7 +1264,9 @@ static int decode_block(AVCodecContext *avctx, void *tdata, line_offset = AV_RL64(s->gb.buffer + jobnr * 8); if (s->is_tile) { - if (buf_size < 20 || line_offset > buf_size - 20) + const int header_size = 20 + (s->is_multipart ? 4 : 0); + + if (buf_size < header_size || line_offset > buf_size - header_size) return AVERROR_INVALIDDATA; src = buf + line_offset + 20; @@ -1277,7 +1279,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, tile_level_y = AV_RL32(src - 8); data_size = AV_RL32(src - 4); - if (data_size <= 0 || data_size > buf_size - line_offset - 20) + if (data_size <= 0 || data_size > buf_size - line_offset - header_size) return AVERROR_INVALIDDATA; if (tile_level_x || tile_level_y) { /* tile level, is not the full res level */ @@ -1307,7 +1309,9 @@ static int decode_block(AVCodecContext *avctx, void *tdata, td->channel_line_size = td->xsize * s->current_channel_offset;/* uncompress size of one line */ uncompressed_size = td->channel_line_size * (uint64_t)td->ysize;/* uncompress size of the block */ } else { - if (buf_size < 8 || line_offset > buf_size - 8) + const int header_size = 8 + (s->is_multipart ? 4 : 0); + + if (buf_size < header_size || line_offset > buf_size - header_size) return AVERROR_INVALIDDATA; src = buf + line_offset + 8; @@ -1319,7 +1323,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, return AVERROR_INVALIDDATA; data_size = AV_RL32(src - 4); - if (data_size <= 0 || data_size > buf_size - line_offset - 8) + if (data_size <= 0 || data_size > buf_size - line_offset - header_size) return AVERROR_INVALIDDATA; td->ysize = FFMIN(s->scan_lines_per_block, s->ymax - line + 1); /* s->ydelta - line ?? */ -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
