diff options
author | Andrew Jones <drjones@redhat.com> | 2017-06-02 11:51:46 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-06-02 11:51:46 +0100 |
commit | a18e93125de1ce8caf1d6c00cc7f6f0c96f7854f (patch) | |
tree | dea4903fc96d394e382de2298dd5e0fda9539579 /hw/core/loader.c | |
parent | 993063fbb531d11f7ede59e5264308eafa6ee4ff (diff) |
load_uboot_image: don't assume a full header read
Don't allow load_uboot_image() to proceed when less bytes than
header-size was read.
Signed-off-by: Andrew Jones <drjones@redhat.com>
Message-id: 20170524091315.20284-1-drjones@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/core/loader.c')
-rw-r--r-- | hw/core/loader.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/core/loader.c b/hw/core/loader.c index bf17b42cbe..f72930ca4a 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -611,8 +611,9 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr, return -1; size = read(fd, hdr, sizeof(uboot_image_header_t)); - if (size < 0) + if (size < sizeof(uboot_image_header_t)) { goto out; + } bswap_uboot_header(hdr); |