]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mcookie: fix infinite-loop when use -f
authorHiroaki Sengoku <sengoku@senri.gcd.org>
Fri, 15 Oct 2021 05:02:46 +0000 (14:02 +0900)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Oct 2021 11:08:37 +0000 (13:08 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/mcookie.c

index 315740127e1598fbb1aa06bc6d50468ac294d465..be5c34ae4c00e5ffe0d33efd166ec44fe036b5d7 100644 (file)
@@ -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;