Skip to content

Commit bf660b6

Browse files
authored
Add warning for big-endian squashfs filesystems (#32)
1 parent 0887fd2 commit bf660b6

25 files changed

+63
-15
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/_data/** filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
coverage.xml
22
.coverage
3+
build/
34
dist/
45
.eggs/
56
*.egg-info/
67
*.pyc
78
__pycache__/
89
.pytest_cache/
9-
tests/docs/api
10-
tests/docs/build
10+
tests/_docs/api
11+
tests/_docs/build
1112
.tox/

dissect/squashfs/c_squashfs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from dissect.cstruct import cstruct
66

77
squashfs_def = """
8-
#define SQUASHFS_MAGIC 0x73717368
8+
#define SQUASHFS_MAGIC 0x73717368
9+
#define SQUASHFS_MAGIC_SWAP 0x68737173
910
1011
/* size of metadata (inode and directory) blocks */
1112
#define SQUASHFS_METADATA_SIZE 8192

dissect/squashfs/squashfs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self, fh: BinaryIO):
3333

3434
sb = c_squashfs.squashfs_super_block(fh)
3535
if sb.s_magic != c_squashfs.SQUASHFS_MAGIC:
36+
if sb.s_magic == c_squashfs.SQUASHFS_MAGIC_SWAP:
37+
raise NotImplementedError("Unsupported squashfs pre-4.0 big-endian filesystem")
38+
3639
raise ValueError("Invalid squashfs superblock")
3740

3841
# Only support squashfs 4.x for now

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ select = [
9898
ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM105", "TRY003"]
9999

100100
[tool.ruff.lint.per-file-ignores]
101-
"tests/docs/**" = ["INP001"]
101+
"tests/_docs/**" = ["INP001"]
102102

103103
[tool.ruff.lint.isort]
104104
known-first-party = ["dissect.squashfs"]

tests/_data/gzip-opts.sqfs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:8bfb0b9136b815bb5e3d46e0fa1b43cae6d610e0b317e93d2a9796ae1b04e5ee
3+
size 12288

tests/_data/gzip.sqfs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:7f023874793b8209d4734c286df3936181490fa269738fd8279afc162e68e6e1
3+
size 12288

tests/_data/lz4.sqfs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:8379d6714b924a08ea3ed9d4a7dd74fbe9855c1c5e0eef7faef32ceb0245769e
3+
size 24576

tests/_data/lzma.sqfs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:04cbf7d47cff6ae34c248f1b54b815d6d9262b9c1404479c10197fbe87c6693c
3+
size 8192

tests/_data/lzo.sqfs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:a95508fff68c11f01b485b02bc3e13d0ec8337aa351d28020455fe7cd916ee1f
3+
size 28672

0 commit comments

Comments
 (0)