From: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by:Vishal Chourasia <vishalc@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251030015306.2279148-1-alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
hw/core/loader.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 8252616fdd..b7638ccd72 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -75,14 +75,20 @@ int64_t get_image_size(const char *filename, Error **errp)
{
int fd;
int64_t size;
+
fd = qemu_open(filename, O_RDONLY | O_BINARY, errp);
- if (fd < 0)
+
+ if (fd < 0) {
return -1;
+ }
+
size = lseek(fd, 0, SEEK_END);
+
if (size < 0) {
error_setg_errno(errp, errno, "lseek failure: %s", filename);
return -1;
}
+
close(fd);
return size;
}
--
2.52.0