summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2017-10-20 19:00:56 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-10-23 09:12:49 +0200
commited5d71ab06bf45e585f9d03049f4730109979aff (patch)
treebb1ee476516beb39c9eb1f45005c004ede9d3d58
parenta10a8e5e502fb5d5a6f945e208bd00a9bdeca5e2 (diff)
downloadbarebox-ed5d71ab06bf45e585f9d03049f4730109979aff.tar.gz
barebox-ed5d71ab06bf45e585f9d03049f4730109979aff.tar.xz
arm: bootm: don't fall over if image is padded with less than 40 bytes
If the zImage has a padding, which is less than 40 bytes (sizeof struct fdt_header) the amount of read bytes would be propagated as an error code. Fix this by only propagating real errors and treating failure to read less than the expected amount as no concatenated DT being present. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/lib/bootm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 8068a53be0..25efb42541 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -250,8 +250,10 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
header = &__header;
ret = read(fd, header, sizeof(*header));
- if (ret < sizeof(*header))
+ if (ret < 0)
return ret;
+ if (ret < sizeof(*header))
+ return -ENXIO;
if (file_detect_type(header, sizeof(*header)) != filetype_oftree)
return -ENXIO;