From bc69c4e5f85eabc986ab516083117567af6baf0e Mon Sep 17 00:00:00 2001 From: lijinlin Date: Wed, 30 Jul 2025 23:10:45 +0800 Subject: [PATCH] backport patch from upstream to fix nine bits decompression failed (cherry picked from commit 3709b8fc1d422c6dee97a3dc7934fba81e7e5406) --- ...processing-updated-reset-code-behavi.patch | 102 ++++++++++++++++++ ncompress.spec | 7 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 backport-fixed-nine-bits-processing-updated-reset-code-behavi.patch diff --git a/backport-fixed-nine-bits-processing-updated-reset-code-behavi.patch b/backport-fixed-nine-bits-processing-updated-reset-code-behavi.patch new file mode 100644 index 0000000..0923f84 --- /dev/null +++ b/backport-fixed-nine-bits-processing-updated-reset-code-behavi.patch @@ -0,0 +1,102 @@ +From 3303f310da2c59188fc93b79ed526cad75db323e Mon Sep 17 00:00:00 2001 +From: Andrew Aladjev +Date: Mon, 8 Feb 2021 08:00:36 +0300 +Subject: [PATCH] fixed nine bits processing, updated reset code behaviour + +Closes #5. + +The problem is that extcode and maxcode together with n_bits were not properly + initialized and reset. I've added code in the same style as code around. +--- + compress.c | 32 ++++++++++++++++++++++---------- + tests/runtests.sh | 5 +++++ + 2 files changed, 27 insertions(+), 10 deletions(-) + +diff --git a/compress.c b/compress.c +index 66cacf1..dc5a006 100644 +--- a/compress.c ++++ b/compress.c +@@ -402,6 +402,24 @@ union bytes + (o) += (n); \ + } + ++#define reset_n_bits_for_compressor(n_bits, stcode, free_ent, extcode, maxbits) { \ ++ n_bits = INIT_BITS; \ ++ stcode = 1; \ ++ free_ent = FIRST; \ ++ extcode = MAXCODE(n_bits); \ ++ if (n_bits < maxbits) \ ++ extcode++; \ ++} ++ ++#define reset_n_bits_for_decompressor(n_bits, bitmask, maxbits, maxcode, maxmaxcode) { \ ++ n_bits = INIT_BITS; \ ++ bitmask = (1<input.Z ++uncompress -c input.Z >input.new ++cmp $COMPRESS input.new ++ + : "### All passed!" +-- +2.43.0 + diff --git a/ncompress.spec b/ncompress.spec index a4410e2..174d2a5 100644 --- a/ncompress.spec +++ b/ncompress.spec @@ -1,6 +1,6 @@ Name: ncompress Version: 5.0 -Release: 1 +Release: 2 Summary: A fast, simple LZW file compressor License: Public Domain URL: http://ncompress.sourceforge.net/ @@ -8,6 +8,8 @@ Source0: https://github.com/vapier/%{name}/archive/v%{version}.tar.gz#/%{ BuildRequires: git gcc glibc-devel +Patch0: backport-fixed-nine-bits-processing-updated-reset-code-behavi.patch + %description Compress is a fast, simple LZW file compressor. Compress does not have the highest compression rate, but it is one of the fastest programs to compress data. Compress @@ -39,6 +41,9 @@ ln -sf compress.1 %{buildroot}%{_mandir}/man1/uncompress.1 %{_mandir}/man1/*.gz %changelog +* Wed Jul 30 2025 lijinlin -5.0-2 +- backport patch from upstream to fix nine bits decompression failed + * Mon Jun 27 2022 dillon chen -5.0-1 - update to 5.0 -- Gitee