Skip to content

Commit

Permalink
Check that bitmap read length is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Garcia committed Dec 8, 2023
1 parent ddee25e commit e4a7aee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion io_scene_halo/file_tag/h1/file_bitmap/process_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def process_file(input_stream, report):
BITMAP.bitmap_body.bitmaps_tag_block = TAG.TagBlock().read(input_stream, TAG, tag_format.XMLData(tag_node, "bitmaps"))

size = input_stream.read(4) # Padding
BITMAP.bitmap_body.compressed_color_plate = input_stream.read(BITMAP.bitmap_body.compressed_color_plate_data.size - 4)
color_plate_length = BITMAP.bitmap_body.compressed_color_plate_data.size - 4
if color_plate_length < 0:
color_plate_length = 0

BITMAP.bitmap_body.compressed_color_plate = input_stream.read(color_plate_length)
BITMAP.bitmap_body.processed_pixels = input_stream.read(BITMAP.bitmap_body.processed_pixel_data.size)

BITMAP.sequences = []
Expand Down
6 changes: 5 additions & 1 deletion io_scene_halo/file_tag/h2/file_bitmap/process_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ def process_file(input_stream, report):
initilize_bitmap(BITMAP)
read_bitmap_body(BITMAP, TAG, input_stream, tag_node, XML_OUTPUT)
size = input_stream.read(4) # Padding
BITMAP.bitmap_body.compressed_color_plate = input_stream.read(BITMAP.bitmap_body.compressed_color_plate_data.size - 4)
color_plate_length = BITMAP.bitmap_body.compressed_color_plate_data.size - 4
if color_plate_length < 0:
color_plate_length = 0

BITMAP.bitmap_body.compressed_color_plate = input_stream.read(color_plate_length)
BITMAP.bitmap_body.processed_pixels = input_stream.read(BITMAP.bitmap_body.processed_pixel_data.size)
read_sequences(BITMAP, TAG, input_stream, tag_node, XML_OUTPUT)
read_bitmaps(BITMAP, TAG, input_stream, tag_node, XML_OUTPUT)
Expand Down

0 comments on commit e4a7aee

Please sign in to comment.