Skip to content

Commit 1f72c09

Browse files
authored
Merge pull request #829 from onekey-sec/zlib-force-start-offset
fix(zlib): Limit zlib pattern at the start of the file
2 parents 92072fd + d2a1bdd commit 1f72c09

File tree

5 files changed

+5
-17
lines changed

5 files changed

+5
-17
lines changed

tests/integration/compression/zlib/__input__/sample.prefix.zlib

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/integration/compression/zlib/__output__/sample.prefix.zlib_extract/0-5.unknown

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/integration/compression/zlib/__output__/sample.prefix.zlib_extract/5-39.zlib

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/integration/compression/zlib/__output__/sample.prefix.zlib_extract/5-39.zlib_extract/zlib.uncompressed

Lines changed: 0 additions & 3 deletions
This file was deleted.

unblob/handlers/compression/zlib.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from unblob.handlers.archive.dmg import DMGHandler
99

1010
from ...file_utils import DEFAULT_BUFSIZE, InvalidInputFormat
11-
from ...models import Extractor, File, Handler, HexString, ValidChunk
11+
from ...models import Extractor, File, Handler, Regex, ValidChunk
1212

1313
logger = get_logger()
1414

@@ -28,10 +28,10 @@ class ZlibHandler(Handler):
2828
NAME = "zlib"
2929

3030
PATTERNS = [
31-
HexString("78 01"), # low compression
32-
HexString("78 9c"), # default compression
33-
HexString("78 da"), # best compression
34-
HexString("78 5e"), # compressed
31+
Regex(r"^\x78\x01"), # low compression
32+
Regex(r"^\x78\x9c"), # default compression
33+
Regex(r"^\x78\xda"), # best compression
34+
Regex(r"^\x78\x5e"), # compressed
3535
]
3636

3737
EXTRACTOR = ZlibExtractor()

0 commit comments

Comments
 (0)