summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-01-16 20:45:05 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-17 09:42:05 +0100
commit64e88dd12960c6d629f997c4ee552377f597db02 (patch)
treec19337631e51040513502278ffd68229b139eb40 /crypto
parentb977190f929188f4f19dd4bc0631cebab1f9d6d3 (diff)
downloadbarebox-64e88dd12960c6d629f997c4ee552377f597db02.tar.gz
barebox-64e88dd12960c6d629f997c4ee552377f597db02.tar.xz
crypto: digest: Return -errno if lseek() fails
Strictly speaking, lseek() doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'. In this case this change also allows us to avoid potential problems from downconverting 'loff_t' to 'int'. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/digest.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/digest.c b/crypto/digest.c
index 493e56902d..230db26e84 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -226,9 +226,9 @@ static int digest_update_from_fd(struct digest *d, int fd,
unsigned char *buf = xmalloc(PAGE_SIZE);
int ret = 0;
- ret = lseek(fd, start, SEEK_SET);
- if (ret == -1) {
+ if (lseek(fd, start, SEEK_SET) != start) {
perror("lseek");
+ ret = -errno;
goto out_free;
}