summaryrefslogtreecommitdiffstats
path: root/crypto/digest.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-05-10 18:15:50 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-10 18:15:50 +0200
commitbac01839b063697200d5b957b652da197b8f0b1d (patch)
tree8b2441ee12fd42abf152d990eda478aaf722e4e9 /crypto/digest.c
parent65cfdbebb19f0b1c8d322a3eb9ec464d669a4d3f (diff)
parenta306c1c0bd09e7ee074d113b8a86bd815ef64017 (diff)
downloadbarebox-bac01839b063697200d5b957b652da197b8f0b1d.tar.gz
barebox-bac01839b063697200d5b957b652da197b8f0b1d.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'crypto/digest.c')
-rw-r--r--crypto/digest.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto/digest.c b/crypto/digest.c
index 2c4de2e4f1..360c261e40 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -233,17 +233,18 @@ static int digest_update_from_fd(struct digest *d, int fd,
}
while (size) {
- const ssize_t now = read(fd, buf, PAGE_SIZE);
- if (now < 0) {
- ret = now;
+ unsigned long now = min_t(typeof(size), PAGE_SIZE, size);
+
+ ret = read(fd, buf, now);
+ if (ret < 0) {
perror("read");
goto out_free;
}
- if (!now)
+ if (!ret)
break;
- ret = digest_update_interruptible(d, buf, now);
+ ret = digest_update_interruptible(d, buf, ret);
if (ret)
goto out_free;