From 6342bfcb8363cee4a3e37db7335e5ca1b2b37a9d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 7 Apr 2025 13:41:33 +0100 Subject: [PATCH] Fix nbdcopy --blkhash crash resolves: RHEL-85513 --- ...hen-blkhash-size-is-not-a-power-of-2.patch | 33 +++++++++++++++++++ libnbd.spec | 5 +-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 0006-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch diff --git a/0006-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch b/0006-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch new file mode 100644 index 0000000..3e9a905 --- /dev/null +++ b/0006-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch @@ -0,0 +1,33 @@ +From bf2babeaea87958f587e67ff73b27e9bfe7544a1 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 7 Apr 2025 11:35:25 +0100 +Subject: [PATCH] copy: Fix crash when blkhash size is not a power of 2 + +nbdcopy: blkhash.c:105: init_blkhash: Assertion `is_power_of_2 (blkhash_size)' failed. + +The check for this was wrong, resulting in a later assertion failure +instead of an error message. + +Reported-by: Vera Wu +Fixes: https://issues.redhat.com/browse/RHEL-85513 +(cherry picked from commit 6c6e0822c854e423d79bef87caf1c20c5bdb5eb5) +--- + copy/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/copy/main.c b/copy/main.c +index 1a854d5f..07897e79 100644 +--- a/copy/main.c ++++ b/copy/main.c +@@ -220,7 +220,7 @@ main (int argc, char *argv[]) + prog, "--blkhash", error, pstr); + exit (EXIT_FAILURE); + } +- if (! is_power_of_2 (blkhash_size)) { ++ if (! is_power_of_2 (i64)) { + fprintf (stderr, "%s: %s is not a power of two: %s\n", + prog, "--blkhash", &optarg[i+1]); + exit (EXIT_FAILURE); +-- +2.47.1 + diff --git a/libnbd.spec b/libnbd.spec index ac0cd5e..be98b28 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -21,7 +21,7 @@ Name: libnbd Version: 1.22.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NBD client library in userspace License: LGPL-2.0-or-later AND BSD-3-Clause @@ -46,6 +46,7 @@ Patch0002: 0002-copy-progress-Add-a-comment-about-size-and-pipes.patch Patch0003: 0003-copy-Set-the-total-size-in-bytes-copied.patch Patch0004: 0004-info-info-uri-nbds.sh-Fix-test-if-compiled-without-G.patch Patch0005: 0005-copy-Add-blkhash-option.patch +Patch0006: 0006-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch %if 0%{verify_tarball_signature} BuildRequires: gnupg2 @@ -386,7 +387,7 @@ make %{?_smp_mflags} check || { %changelog -* Mon Mar 31 2025 Richard W.M. Jones - 1.22.1-2 +* Mon Apr 07 2025 Richard W.M. Jones - 1.22.1-3 - Rebase to libnbd 1.22.1 - Synch spec file with Fedora Rawhide. resolves: RHEL-78831