forge
Explore
Log in

Don't you dare go Hollow

A tiled HEVC counts its entry points past a u8

Browse files at this commit

907dae075e30f9fa5592287a448f65209e5e7b21Ahmet Kaan GümüşParent: a893c91
  • fix
    • a tiled HEVC counts its entry points past a u8
Show full message
🐛 fix(decode): a tiled HEVC counts its entry points past a u8

§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.rsmodified+9 -1
@@ -4112,7 +4112,15 @@ impl Parser {
4112 let max = if !pps.tiles_enabled_flag && pps.entropy_coding_sync_enabled_flag {4112 let max = if !pps.tiles_enabled_flag && pps.entropy_coding_sync_enabled_flag {
4113 sps.pic_height_in_ctbs_y - 14113 sps.pic_height_in_ctbs_y - 1
4114 } else if pps.tiles_enabled_flag && !pps.entropy_coding_sync_enabled_flag {4114 } else if pps.tiles_enabled_flag && !pps.entropy_coding_sync_enabled_flag {
4115- u32::from((pps.num_tile_columns_minus1 + 1) * (pps.num_tile_rows_minus1 + 1) - 1)4115+ // Widened first: the tile counts are `u8`, and §7.4.3.3.1 lets
4116+ // this parser accept 20 columns by 22 rows, whose product is
4117+ // 440 -- past a `u8` long before it is past the §7.4.7.1 bound.
4118+ // Multiplied narrow it wrapped to 183 in release (every entry
4119+ // point past the 184th refused on a conformant stream, which is
4120+ // this bug's own black picture again) and panicked in debug.
4121+ (u32::from(pps.num_tile_columns_minus1) + 1)
4122+ * (u32::from(pps.num_tile_rows_minus1) + 1)
4123+ - 1
4116 } else {4124 } else {
4117 (u32::from(pps.num_tile_columns_minus1) + 1) * sps.pic_height_in_ctbs_y - 14125 (u32::from(pps.num_tile_columns_minus1) + 1) * sps.pic_height_in_ctbs_y - 1
4118 };4126 };