From eae44ac6322312732a27e57d3cbfb78c5f2e13cc Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 6 Mar 2019 23:49:18 -0800 Subject: 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 Signed-off-by: Sascha Hauer --- common/uimage.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'common/uimage.c') diff --git a/common/uimage.c b/common/uimage.c index 3273bc1871..72b668e898 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); -- cgit v1.2.3