Include upstream fix for bug 1985561

From a comment on the bug:
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.
This commit is contained in:
Bruno Wolff III 2021-07-26 07:23:53 -05:00
parent 081359eb42
commit dae6dc6e91
2 changed files with 39 additions and 1 deletions

30
fix-sparse.patch Normal file
View File

@ -0,0 +1,30 @@
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index aaa4b002bd87..127df00fb789 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -2190,10 +2190,23 @@ static struct file_info *duplicate(int *dupf, int *block_dup, long long file_siz
/* Yes, the block list matches. We can use this, rather
* than writing an identical block list.
* If both it and us doesn't have a tail-end fragment, then we're
- * finished. Return the duplicate */
+ * finished. Return the duplicate.
+ *
+ * We have to deal with the special case where the
+ * last block is a sparse block. This means the
+ * file will have matched, but, it may be a different
+ * file length (because a tail-end sparse block may be
+ * anything from 1 byte to block_size - 1 in size, but
+ * stored as zero). We can still use the block list in
+ * this case, but, we must return a new entry with the
+ * correct file size */
if(!frag_bytes && !dupl_ptr->fragment->size) {
*dupf = *block_dup = TRUE;
- return dupl_ptr;
+ if(file_size == dupl_ptr->file_size)
+ return dupl_ptr;
+ else
+ return create_non_dup(file_size, bytes, blocks, sparse, dupl_ptr->block_list,
+ dupl_ptr->start, dupl_ptr->fragment, checksum, 0, checksum_flag, FALSE);
}
/* We've got a tail-end fragment, and this file most likely

View File

@ -2,7 +2,7 @@ Summary: Utility for the creation of squashfs filesystems
%global forgeurl https://github.com/plougher/squashfs-tools %global forgeurl https://github.com/plougher/squashfs-tools
Version: 4.5 Version: 4.5
Name: squashfs-tools Name: squashfs-tools
Release: 1%{?dist} Release: 2%{?dist}
License: GPLv2+ License: GPLv2+
URL: %{forgeurl}/archive/4.5.tar.gz URL: %{forgeurl}/archive/4.5.tar.gz
Source: 4.5.tar.gz Source: 4.5.tar.gz
@ -11,6 +11,10 @@ Source: 4.5.tar.gz
# Man pages still need a lot of changes for 4.5 # Man pages still need a lot of changes for 4.5
Source1: mksquashfs.1 Source1: mksquashfs.1
Source2: unsquashfs.1 Source2: unsquashfs.1
# Mksquashfs: fix duplicate check when last file block is sparse
# git diff 19b161c1cd3e31f7a396ea92dea4390ad43f27b9^ 19b161c1cd3e31f7a396ea92dea4390ad43f27b9 > fix-sparse.patch
# https://bugzilla.gnome.org/show_bug.cgi?id=1985561
Patch0: fix-sparse.patch
BuildRequires: make BuildRequires: make
BuildRequires: gcc BuildRequires: gcc
@ -27,6 +31,7 @@ contains the utilities for manipulating squashfs filesystems.
%prep %prep
%setup -n %{name}-4.5 %setup -n %{name}-4.5
%patch0 -p1
%build %build
%set_build_flags %set_build_flags
@ -54,6 +59,9 @@ ln -s unsquashfs %{buildroot}%{_sbindir}/sqfscat
%{_sbindir}/sqfscat %{_sbindir}/sqfscat
%changelog %changelog
* Mon Jul 26 2021 Bruno Wolff III <bruno@wolff.to> - 4.5-2
- Fix for sparse fragment bug 1985561
* Fri Jul 23 2021 Bruno Wolff III <bruno@wolff.to> - 4.5-1 * Fri Jul 23 2021 Bruno Wolff III <bruno@wolff.to> - 4.5-1
- First crack at 4.5 release - First crack at 4.5 release
- Man pages still need significant work - Man pages still need significant work