From 4085e3d19456e046f20725bc0414e77a30dcc529 Mon Sep 17 00:00:00 2001 From: ColdWindScholar <3590361911@qq.com> Date: Mon, 5 Feb 2024 00:26:57 +0800 Subject: [PATCH] [Update] Fix ROM Unpack --- ext4.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ext4.py b/ext4.py index 9a99ff1..ff3242f 100644 --- a/ext4.py +++ b/ext4.py @@ -515,7 +515,7 @@ def get_block_count(self): def get_info_list(self): data = [ ['Filesystem magic number', hex(self.superblock.s_magic).upper()], - ["Filesystem volume name",self.superblock.s_volume_name.decode()], + ["Filesystem volume name", self.superblock.s_volume_name.decode()], ["Filesystem UUID", self.uuid], ['Last mounted on', self.superblock.s_last_mounted.decode()], ["Block size", f"{1 << (10 + self.superblock.s_log_block_size)}"], @@ -849,21 +849,21 @@ def xattrs(self, check_inline=True, check_block=True, force_inline=False): if check_block and self.inode.i_file_acl != 0: xattrs_block_start = self.inode.i_file_acl * self.volume.block_size xattrs_block = self.volume.read(xattrs_block_start, self.volume.block_size) - - xattrs_header = ext4_xattr_header.from_buffer_copy(xattrs_block) - if not self.volume.ignore_magic and xattrs_header.h_magic != 0xEA020000: - try: - raise MagicError( - f"Invalid magic value in xattrs block header at offset 0x{xattrs_block_start:X} of " - f"inode {self.inode_idx:d}: 0x{xattrs_header.h_magic} (expected 0xEA020000)" - ) - except BaseException and Exception: - ... - - if xattrs_header.h_blocks != 1: - raise Ext4Error( - f"Invalid number of xattr blocks at offset 0x{xattrs_block_start:X} " - f"of inode {self.inode_idx:d}: {xattrs_header.h_blocks:d} (expected 1)") + if xattrs_block: + xattrs_header = ext4_xattr_header.from_buffer_copy(xattrs_block) + if not self.volume.ignore_magic and xattrs_header.h_magic != 0xEA020000: + try: + raise MagicError( + f"Invalid magic value in xattrs block header at offset 0x{xattrs_block_start:X} of " + f"inode {self.inode_idx:d}: 0x{xattrs_header.h_magic} (expected 0xEA020000)" + ) + except BaseException and Exception: + ... + + if xattrs_header.h_blocks != 1: + raise Ext4Error( + f"Invalid number of xattr blocks at offset 0x{xattrs_block_start:X} " + f"of inode {self.inode_idx:d}: {xattrs_header.h_blocks:d} (expected 1)") offset = 4 * ((ctypes.sizeof( ext4_xattr_header) + 3) // 4)