Cramfs: "Data Error" on files with holes (mkfs.cramfs -z)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start with CramfsHandler.cpp and inspect CHandler::ReadBlock, where the issue says zero-length compressed blocks are passed to zlib. Compare the existing zero-block handling in SquashfsHandler.cpp and verify how CRAMFS_FLAG_HOLES represents holes. Done means 7-Zip extracts the reported sparse file correctly, including zero-filled blocks; the payload does not name a test file or command for the project suite.
Written by the indexing model from the issue text.
Description
7-Zip 26.06 (x64, Linux) fails on cramfs images made with mkfs.cramfs -z (CRAMFS_FLAG_HOLES) when a file has all-zero pages:
mkdir -p src
{ printf start; head -c 20480 /dev/zero; printf end; } > src/sparse.bin
mkfs.cramfs -z src holes.img
7z x holes.img -oout
Result: ERROR: Data Error : sparse.bin, and the output file stops at 4096 bytes (same on Windows 11 with 7z2606-x64). Without -z the same tree extracts fine. Same result for big-endian images (-N big). The Linux kernel mounts holes.img and reads the file correctly.
With -z, a hole is stored as a block of compressed length 0 (block pointer equal to the previous one). The Linux driver reads it as a page of zeros (fs/cramfs/inode.c, if (block_len == 0) ; /* hole */ then memset). CHandler::ReadBlock in CramfsHandler.cpp passes the empty block to the zlib decoder, which fails. SquashfsHandler.cpp already handles the same case in its ReadBlock (if (packBlockSize == 0) memset(dest, 0, blockSize)).
This change in CHandler::ReadBlock fixes it for me (extracted files are identical to the originals, also for all-zero files and when the first or last block is a hole):
const UInt32 inSize = end - start;
+ if (inSize == 0)
+ {
+ // hole (CRAMFS_FLAG_HOLES): Linux reads a zero-length block as zeros
+ memset(dest, 0, blockSize);
+ return S_OK;
+ }
+
if (_method == k_Flags_Method_LZMA)
- Dominant language
- C++
- Stars
- 4.6k
- Forks
- 519
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ip7z/7zip
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lemonade-sdk/lemonade#4349 ·
Maintainers usually reply within 1 day
-
Python example: list a model's scenes and their camerasPossibly taken @rudraparmar76 claimed this today. Opendocumentation good first issue python
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
iamahsanmehmood/openskp#796 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tenstorrent/tt-umd#4183 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
odelaneau/GLIMPSE#353 · 1 comment ·
Maintainers usually reply within 4 days