util-linux/backport-mcookie-fix-infinite-loop-when-use-f.patch
2023-11-28 16:33:43 +08:00

24 lines
725 B
Diff

From 60e5bb73990260836b087735a9c69deab8af4c81 Mon Sep 17 00:00:00 2001
From: Hiroaki Sengoku <sengoku@senri.gcd.org>
Date: Fri, 15 Oct 2021 14:02:46 +0900
Subject: [PATCH] mcookie: fix infinite-loop when use -f
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/mcookie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
index 315740127e..be5c34ae4c 100644
--- a/misc-utils/mcookie.c
+++ b/misc-utils/mcookie.c
@@ -65,7 +65,7 @@ static uint64_t hash_file(struct mcookie_control *ctl, int fd)
rdsz = wanted - count;
r = read_all(fd, (char *) buf, rdsz);
- if (r < 0)
+ if (r <= 0)
break;
ul_MD5Update(&ctl->ctx, buf, r);
count += r;