Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Mksquashfs: fix duplicate check when last file block is sparse
Bruno Wolf III has reported a bug against the latest release (https://bugzilla.redhat.com/show_bug.cgi?id=1985561). This is a regression caused by rewriting the duplicate checking code to be more aggressive when looking for duplicates when using tail-end packing. In particular a file doesn't now have to be the same size to be considered a (partial) duplicate. Unfortunately, the code didn't handle the special case where the last block in a file is sparse. This previously wasn't an issue because files considered to a duplicate were always the same size, and so the special case did not occur. The reason why the bug occurs when the last block is sparse, is because you get identical block lists even if the file size is different. This is because the tail-end sparse block represents a length between 1 byte and block size - 1, but is stored as 0 (to indicate sparsely stored). To make this concrete, consider two files (128K blocks). 1. File 1 is 128K + 10 bytes in length. The last block (10 bytes) is ZERO filled. The first block has data, compresses to 32K. The block list will hold block 0: 32K block 1: 0 2. File 2 is 128K + 4096 bytes in length. The last block (4096 bytes) is ZERO filled. The first block has identical data to file 1, compresses to 32K The block list will hold block 0: 32K block 1: 0 So the block data is identical, *except* for the fact the tail-end sparse block represents a different amount of data. The duplicate checking code didn't deal with this special case, and in the case of file 2, it would return file 1, effectively truncating most of the trailing ZERO filed data. The fix is to recognise this special case, and to return a new entry with the correct file size and the duplicate data blocks and block list. Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
- Loading branch information