From 907dae075e30f9fa5592287a448f65209e5e7b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 12 Aug 2026 21:00:37 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(decode):=20a=20tiled=20HEVC?= =?UTF-8?q?=20counts=20its=20entry=20points=20past=20a=20u8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit §7.4.7.1 bounds num_entry_point_offsets for a tiles-without-wavefront stream by (num_tile_columns) * (num_tile_rows) - 1, and this parser accepts up to 20 columns by 22 rows -- 440, which it computed in u8 because both counts are u8. Release wrapped it to 183, so a conformant stream's 184th entry point onward was refused and the picture never arrived; a debug build panicked on the multiply. Widened before the multiply, where the spec does the arithmetic. Sibling of fbd4a24 (a real-library 4K wavefront HEVC HDR film's 33 entry points in a [u32; 32]), found by sweeping that fix's own line pair for the same shape. --- vendor/cros-codecs/src/codec/h265/parser.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vendor/cros-codecs/src/codec/h265/parser.rs b/vendor/cros-codecs/src/codec/h265/parser.rs index d9a9cff..3379039 100644 --- a/vendor/cros-codecs/src/codec/h265/parser.rs +++ b/vendor/cros-codecs/src/codec/h265/parser.rs @@ -4112,7 +4112,15 @@ impl Parser { let max = if !pps.tiles_enabled_flag && pps.entropy_coding_sync_enabled_flag { sps.pic_height_in_ctbs_y - 1 } else if pps.tiles_enabled_flag && !pps.entropy_coding_sync_enabled_flag { - u32::from((pps.num_tile_columns_minus1 + 1) * (pps.num_tile_rows_minus1 + 1) - 1) + // Widened first: the tile counts are `u8`, and §7.4.3.3.1 lets + // this parser accept 20 columns by 22 rows, whose product is + // 440 -- past a `u8` long before it is past the §7.4.7.1 bound. + // Multiplied narrow it wrapped to 183 in release (every entry + // point past the 184th refused on a conformant stream, which is + // this bug's own black picture again) and panicked in debug. + (u32::from(pps.num_tile_columns_minus1) + 1) + * (u32::from(pps.num_tile_rows_minus1) + 1) + - 1 } else { (u32::from(pps.num_tile_columns_minus1) + 1) * sps.pic_height_in_ctbs_y - 1 };