summaryrefslogtreecommitdiffstats
path: root/common/uimage.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:18 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:46 +0100
commiteae44ac6322312732a27e57d3cbfb78c5f2e13cc (patch)
tree5bf6efd1e1c04cf463ce60efa61ed8a7d8a18bd5 /common/uimage.c
parentcf6e01e07f0eb838c1a08756bd3cc575221d7730 (diff)
downloadbarebox-eae44ac6322312732a27e57d3cbfb78c5f2e13cc.tar.gz
uimage: Fix lseek error check in uimage_verify()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/uimage.c')
-rw-r--r--common/uimage.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/uimage.c b/common/uimage.c
index 3273bc1..72b668e 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -265,11 +265,12 @@ int uimage_verify(struct uimage_handle *handle)
{
u32 crc = 0;
int len, ret;
+ loff_t off;
void *buf;
- ret = lseek(handle->fd, sizeof(struct image_header), SEEK_SET);
- if (ret < 0)
- return ret;
+ off = sizeof(struct image_header);
+ if (lseek(handle->fd, off, SEEK_SET) != off)
+ return -errno;
buf = xmalloc(PAGE_SIZE);