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
114 changes: 113 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ packages = [{include = "ubireader"}]
python = ">=3.10"
lzallright = "^0.2.1"
cryptography = ">=44.0.2,<47.0.0"
zstandard = "^0.25.0"

[build-system]
requires = ["poetry-core"]
Expand Down
12 changes: 9 additions & 3 deletions ubireader/ubifs/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from lzallright import LZOCompressor
import struct
import zlib
import zstandard
from ubireader.ubifs.defines import *
from ubireader.debug import error, verbose_log
from ubireader.debug import error
Expand Down Expand Up @@ -66,9 +67,9 @@ def decompress(ctype: int, unc_len: int, data: bytes) -> bytes | None:
"""Decompress data.

Arguments:
Int:ctype -- Compression type LZO, ZLIB (*currently unused*).
Int:unc_len -- Uncompressed data lenth.
Str:data -- Data to be uncompessed.
Int:ctype -- Compression type LZO, ZLIB, or ZSTD.
Int:unc_len -- Uncompressed data length.
Str:data -- Data to be uncompressed.

Returns:
Uncompressed Data.
Expand All @@ -83,6 +84,11 @@ def decompress(ctype: int, unc_len: int, data: bytes) -> bytes | None:
return zlib.decompress(data, -11)
except Exception as e:
error(decompress, 'Warn', 'ZLib Error: %s' % e)
elif ctype == UBIFS_COMPR_ZSTD:
try:
return zstandard.decompress(data, max_output_size=unc_len)
except Exception as e:
error(decompress, 'Warn', 'ZSTD Error: %s' % e)
else:
return data

Expand Down
Loading