Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-07-15 07:52:32 +0300
committerCampbell Barton <campbell@blender.org>2022-07-15 07:53:38 +0300
commitd14d5705807c8216f3cfb1de3af6f448a1401599 (patch)
treec00d8fcb4cc34f0b330dae59433ebb9b3e2ddd6f
parentc8e8f107bf82fb56f49101e1098f4c697b16cfeb (diff)
blend_render_info: add check for negative BHead length (corrupt file)
Without this check, corrupt files would raise a Python exception, now early exit with a useful error.
-rwxr-xr-xrelease/scripts/modules/blend_render_info.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py
index 37c5f6dd3ba..6b45a6f7e72 100755
--- a/release/scripts/modules/blend_render_info.py
+++ b/release/scripts/modules/blend_render_info.py
@@ -93,6 +93,11 @@ def _read_blend_rend_chunk_from_file(blendfile, filepath):
break
sizeof_data_left = struct.unpack('>i' if is_big_endian else '<i', blendfile.read(4))[0]
+ if sizeof_data_left < 0:
+ # Very unlikely, but prevent other errors.
+ sys.stderr.write("Negative block size found (corrupt file): %s\n" % filepath)
+ break
+
# 4 from the `head_id`, another 4 for the size of the BHEAD.
sizeof_bhead_left = sizeof_bhead - 8