summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:20 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:46 +0100
commit7af10336201f9d458a4f7baefec4d0d8a8c60141 (patch)
tree4b57ff050e073c03678c8108688c401d7d08e5d3 /common
parentcb4b3d397361e04a5de1da71e84522f6bfba11ba (diff)
downloadbarebox-7af10336201f9d458a4f7baefec4d0d8a8c60141.tar.gz
barebox-7af10336201f9d458a4f7baefec4d0d8a8c60141.tar.xz
uimage: Fix lseek error check in uimage_load_to_buf()
Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/uimage.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/common/uimage.c b/common/uimage.c
index 12c7e9e2c1..35bfb10b06 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -457,6 +457,7 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no,
{
u32 size;
int ret;
+ loff_t off;
struct uimage_handle_data *ihd;
char ftbuf[128];
enum filetype ft;
@@ -467,9 +468,8 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no,
ihd = &handle->ihd[image_no];
- ret = lseek(handle->fd, ihd->offset + handle->data_offset,
- SEEK_SET);
- if (ret < 0)
+ off = ihd->offset + handle->data_offset;
+ if (lseek(handle->fd, off, SEEK_SET) != off)
return NULL;
if (handle->header.ih_comp == IH_COMP_NONE) {
@@ -497,10 +497,8 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no,
if (ft != filetype_gzip)
return NULL;
- ret = lseek(handle->fd, ihd->offset + handle->data_offset +
- ihd->len - 4,
- SEEK_SET);
- if (ret < 0)
+ off = ihd->offset + handle->data_offset + ihd->len - 4;
+ if (lseek(handle->fd, off, SEEK_SET) != off)
return NULL;
ret = read(handle->fd, &size, 4);
@@ -509,9 +507,8 @@ void *uimage_load_to_buf(struct uimage_handle *handle, int image_no,
size = le32_to_cpu(size);
- ret = lseek(handle->fd, ihd->offset + handle->data_offset,
- SEEK_SET);
- if (ret < 0)
+ off = ihd->offset + handle->data_offset;
+ if (lseek(handle->fd, off, SEEK_SET) != off)
return NULL;
buf = malloc(size);