Fix nbdcopy --blkhash crash

resolves: RHEL-85513
This commit is contained in:
Richard W.M. Jones 2025-04-07 13:41:33 +01:00
parent 0d12e607e8
commit 6342bfcb83
2 changed files with 36 additions and 2 deletions

View File

@ -0,0 +1,33 @@
From bf2babeaea87958f587e67ff73b27e9bfe7544a1 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
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

View File

@ -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 <rjones@redhat.com> - 1.22.1-2
* Mon Apr 07 2025 Richard W.M. Jones <rjones@redhat.com> - 1.22.1-3
- Rebase to libnbd 1.22.1
- Synch spec file with Fedora Rawhide.
resolves: RHEL-78831