diff --git a/0001-Revert-Fix-checksum-failure-with-small-isos.patch b/0001-Revert-Fix-checksum-failure-with-small-isos.patch new file mode 100644 index 0000000..505d006 --- /dev/null +++ b/0001-Revert-Fix-checksum-failure-with-small-isos.patch @@ -0,0 +1,67 @@ +From 14e4bac91c6aba61fe56c8d9a59cf7f07dbb99ab Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 29 Apr 2024 11:35:14 -0700 +Subject: [PATCH] Revert "Fix checksum failure with small isos" + +This reverts commit e313746011768ed69587fcda88ff65951af90ccc. + +This patch causes short checksums (57 characters instead of 60) to be +written, resulting in a checksum that doesn't cover the whole iso and +which fails when checked with previous checkisomd5sum versions. + +The incorrect checksums are shown with a ';FR' at the end instead of the +last 3 digits. +--- + libcheckisomd5.c | 4 ++-- + libimplantisomd5.c | 6 +++--- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/libcheckisomd5.c b/libcheckisomd5.c +index adcd938..2d350bc 100644 +--- a/libcheckisomd5.c ++++ b/libcheckisomd5.c +@@ -66,7 +66,7 @@ static enum isomd5sum_status checkmd5sum(int isofd, checkCallback cb, void *cbda + size_t previous_fragment = 0UL; + off_t offset = 0LL; + while (offset < total_size) { +- const size_t nbyte = MIN((size_t)(total_size - offset), MIN(fragment_size, buffer_size)); ++ const size_t nbyte = MIN((size_t)(total_size - offset), buffer_size); + + ssize_t nread = read(isofd, buffer, nbyte); + if (nread <= 0L) +@@ -89,7 +89,7 @@ static enum isomd5sum_status checkmd5sum(int isofd, checkCallback cb, void *cbda + const size_t current_fragment = offset / fragment_size; + const size_t fragmentsize = FRAGMENT_SUM_SIZE / info->fragmentcount; + /* If we're onto the next fragment, calculate the previous sum and check. */ +- if (current_fragment != previous_fragment && current_fragment < info->fragmentcount) { ++ if (current_fragment != previous_fragment) { + if (!validate_fragment(&hashctx, current_fragment, fragmentsize, + info->fragmentsums, NULL)) { + /* Exit immediately if current fragment sum is incorrect */ +diff --git a/libimplantisomd5.c b/libimplantisomd5.c +index d5f32fc..217c896 100644 +--- a/libimplantisomd5.c ++++ b/libimplantisomd5.c +@@ -109,8 +109,8 @@ int implantISOFD(int isofd, int supported, int forceit, int quiet, char **errstr + const off_t fragment_size = total_size / (FRAGMENT_COUNT + 1); + size_t previous_fragment = 0UL; + off_t offset = 0LL; +- while (offset < total_size && previous_fragment < FRAGMENT_COUNT) { +- const size_t nbyte = MIN((size_t)(total_size - offset), MIN(fragment_size, buffer_size)); ++ while (offset < total_size) { ++ const size_t nbyte = MIN((size_t)(total_size - offset), buffer_size); + ssize_t nread = read(isofd, buffer, nbyte); + if (nread <= 0L) + break; +@@ -119,7 +119,7 @@ int implantISOFD(int isofd, int supported, int forceit, int quiet, char **errstr + const size_t current_fragment = offset / fragment_size; + const size_t fragmentsize = FRAGMENT_SUM_SIZE / FRAGMENT_COUNT; + /* If we're onto the next fragment, calculate the previous sum and check. */ +- if (current_fragment != previous_fragment && current_fragment < FRAGMENT_COUNT) { ++ if (current_fragment != previous_fragment) { + validate_fragment(&hashctx, current_fragment, fragmentsize, NULL, fragmentsums); + previous_fragment = current_fragment; + } +-- +2.44.0 + diff --git a/isomd5sum.spec b/isomd5sum.spec index 3f2a3e1..1bf7015 100644 --- a/isomd5sum.spec +++ b/isomd5sum.spec @@ -3,7 +3,7 @@ Summary: Utilities for working with md5sum implanted in ISO images Name: isomd5sum Version: 1.2.4 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 1 License: GPL-2.0-or-later @@ -12,6 +12,8 @@ License: GPL-2.0-or-later Url: %{forgeurl} Source0: %{forgesource} +Patch0001: 0001-Revert-Fix-checksum-failure-with-small-isos.patch + BuildRequires: gcc BuildRequires: popt-devel BuildRequires: python3-devel @@ -67,6 +69,10 @@ PYTHON=%{__python3} make DESTDIR=$RPM_BUILD_ROOT install-bin install-devel insta %{python3_sitearch}/pyisomd5sum.so %changelog +* Mon Apr 29 2024 Brian C. Lane - 1.2.4-2 +- Revert small iso fix, it resulted in incorrect checksums + Resolves: rhbz#2277398 + * Fri Feb 16 2024 Brian C. Lane - 1.2.4-1 - New Version 1.2.4 (bcl) - Add support for riscv64 (davidlt) diff --git a/tests/smoke.sh b/tests/smoke.sh index 1f2f20e..ce667b2 100755 --- a/tests/smoke.sh +++ b/tests/smoke.sh @@ -8,8 +8,12 @@ mkisofs -o test.iso isocontent # Implant and check md5 sum implantisomd5 test.iso -checkisomd5 --verbose test.iso +checkisomd5 --verbose test.iso 2>&1 | tee test.run.log + +echo "Check implanted checksum for 1.2.4-1 checksum bug" +grep ';FR' test.run.log && exit 1 # Destroy testing iso image rm -rf ./isocontent rm test.iso +rm test.run.log