libnbd/0008-copy-Avoid-potential-divide-by-zero-when-source-size.patch

31 lines
861 B
Diff
Raw Normal View History

From 8d9c9a8141ccacbde2f1ccd350745de60945900c Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 30 Jul 2021 10:57:39 +0100
Subject: [PATCH] copy: Avoid potential divide by zero when source size is zero
Actually this does not happen because of the way the progress bar is
called from other code, but it's possible that a future change might
introduce a bug, so avoid any problems.
(cherry picked from commit 266c6e7083b1e0e8373ce166cf0be388604ca805)
---
copy/progress.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/copy/progress.c b/copy/progress.c
index 7383299..59ec817 100644
--- a/copy/progress.c
+++ b/copy/progress.c
@@ -103,6 +103,8 @@ progress_bar (off_t pos, int64_t size)
if (!progress)
return;
+ if (size == 0)
+ return;
pthread_mutex_lock (&lock);
if (progress_fd == -1)
--
2.31.1