Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ def read_chunk_header(self) -> ChunkHeader:
chunk_type = self.buffer_wrapper.read_u16()
header_size = self.buffer_wrapper.read_u16()
chunk_size = self.buffer_wrapper.read_u32()
try:
parsed_chunk_type: ChunkType | int = ChunkType(chunk_type)
except ValueError:
parsed_chunk_type = chunk_type
return ChunkHeader(
start_offset=start_offset,
chunk_type=ChunkType(chunk_type),
chunk_type=parsed_chunk_type,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown chunk types still crash in parse_resource_table

Medium Severity

The read_chunk_header change now allows unknown chunk type integers to pass through instead of crashing, but parse_resource_table still raises a ValueError in its else branch for any chunk type that isn't STRING_POOL, TABLE_PACKAGE, or NULL. Before this PR, unknown types would crash earlier in read_chunk_header; now they flow through and crash at line 560 instead. Both parse_xml and read_package gracefully skip unknown chunks, but parse_resource_table does not, creating an inconsistency that undermines the forward-compatibility goal.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a14cd7e. Configure here.

header_size=header_size,
chunk_size=chunk_size,
)
Expand Down
5 changes: 4 additions & 1 deletion src/launchpad/parsers/android/binary/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class ChunkType(IntEnum):
TABLE_TYPE = 0x0201
TABLE_TYPE_SPEC = 0x0202
TABLE_LIBRARY = 0x0203
TABLE_OVERLAYABLE = 0x0204
TABLE_OVERLAYABLE_POLICY = 0x0205
TABLE_STAGED_ALIAS = 0x0206


class NodeType(IntEnum):
Expand Down Expand Up @@ -83,7 +86,7 @@ class ChunkHeader:
"""Header for a binary chunk."""

start_offset: int
chunk_type: ChunkType
chunk_type: Union[ChunkType, int]
header_size: int
chunk_size: int

Expand Down
Loading