Skip to content

Commit

Permalink
Merge pull request #635 from onekey-sec/634-fix-zstd-infinite-loop
Browse files Browse the repository at this point in the history
fix(handlers): fix infinite loop in zstd handler.
  • Loading branch information
qkaiser authored Jul 31, 2023
2 parents 3733fb3 + 87ccbea commit 1facc7d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Git LFS file not shown
Empty file.
8 changes: 5 additions & 3 deletions unblob/handlers/compression/zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]

last_block = False
while not last_block:
block_header = int.from_bytes(
file.read(BLOCK_HEADER_LEN), byteorder="little"
)
block_header_val = file.read(BLOCK_HEADER_LEN)
# EOF
if not block_header_val:
raise InvalidInputFormat("Premature end of ZSTD stream.")
block_header = int.from_bytes(block_header_val, byteorder="little")
last_block = block_header >> 0 & 0b1
block_type = block_header >> 1 & 0b11

Expand Down

0 comments on commit 1facc7d

Please sign in to comment.