diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-03-06 23:49:19 -0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-03-11 07:55:46 +0100 |
commit | cb4b3d397361e04a5de1da71e84522f6bfba11ba (patch) | |
tree | 8b98c0412d0563707a34178725f6391a363efd38 /common/uimage.c | |
parent | eae44ac6322312732a27e57d3cbfb78c5f2e13cc (diff) | |
download | barebox-cb4b3d397361e04a5de1da71e84522f6bfba11ba.tar.gz barebox-cb4b3d397361e04a5de1da71e84522f6bfba11ba.tar.xz |
uimage: Fix lseek error check in uimage_load()
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.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/common/uimage.c b/common/uimage.c index 72b668e898..12c7e9e2c1 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -308,6 +308,7 @@ int uimage_load(struct uimage_handle *handle, unsigned int image_no, image_header_t *hdr = &handle->header; struct uimage_handle_data *iha; int ret; + loff_t off; int (*uncompress_fn)(unsigned char *inbuf, int len, int(*fill)(void*, unsigned int), int(*flush)(void*, unsigned int), @@ -320,10 +321,9 @@ int uimage_load(struct uimage_handle *handle, unsigned int image_no, iha = &handle->ihd[image_no]; - ret = lseek(handle->fd, iha->offset + handle->data_offset, - SEEK_SET); - if (ret < 0) - return ret; + off = iha->offset + handle->data_offset; + if (lseek(handle->fd, off, SEEK_SET) != off) + return -errno; /* if ramdisk U-Boot expect to ignore the compression type */ if (hdr->ih_comp == IH_COMP_NONE || hdr->ih_type == IH_TYPE_RAMDISK) |