From e509c6b7a0f50ca7c83f2fa63a7ecd59f3830bb8 Mon Sep 17 00:00:00 2001 From: Lila Date: Sun, 6 Oct 2024 12:06:14 +0100 Subject: [PATCH] bounds check --- fast64_internal/sm64/animation/exporting.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fast64_internal/sm64/animation/exporting.py b/fast64_internal/sm64/animation/exporting.py index dadae5413..f5bc6e93d 100644 --- a/fast64_internal/sm64/animation/exporting.py +++ b/fast64_internal/sm64/animation/exporting.py @@ -860,9 +860,16 @@ def export_animation_binary( data, ) table_address = get64bitAlignedAddr(int_from_str(anim_props.address)) + table_end_address = int_from_str(anim_props.end_address) if anim_props.update_table: for i, header in enumerate(animation.headers): element_address = table_address + (4 * header.table_index) + if element_address > table_end_address: + raise PluginError( + f"Animation header {i + 1} sets table index {header.table_index} which is out of bounds, " + f"table is {table_end_address - table_address} bytes long, " + "update the table start/end addresses in the armature properties" + ) binary_exporter.seek(element_address) binary_exporter.write(encodeSegmentedAddr(animation_address + (i * HEADER_SIZE), segment_data)) if anim_props.update_behavior: