From 7cad780156f2bfb763b43e175a5ee7826471b925 Mon Sep 17 00:00:00 2001 From: amuliang <982632988@qq.com> Date: Wed, 20 Mar 2024 16:24:25 +0800 Subject: [PATCH] =?UTF-8?q?CRC=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- type/PNG.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/type/PNG.py b/type/PNG.py index e2cc200..9d130f8 100644 --- a/type/PNG.py +++ b/type/PNG.py @@ -149,6 +149,15 @@ class PNG: data[height_begin: height_begin+4] = height.to_bytes(4, byteorder='big') print(f'[*] 已将图片高度设置为{height}') changed = True + + chunk_data = data[data_begin: data_begin+length] + if not PNG.test_ihdr_chunk(ctype + chunk_data, crc): + print('[x] 修复CRC校验码') + chunk = ctype + chunk_data + crc32 = binascii.crc32(chunk) & 0xffffffff + data[data_begin+length:data_begin+length+4] = crc32.to_bytes(4, byteorder='big') + changed = True + b = True return changed, data, width, height @staticmethod