[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/6] hw/core/loader: Use ssize_t for efi zboot unpacker
From: |
Bibo Mao |
Subject: |
[PULL 1/6] hw/core/loader: Use ssize_t for efi zboot unpacker |
Date: |
Thu, 9 Jan 2025 14:57:59 +0800 |
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
Convert to use sszie_t to represent size internally to avoid
large image overflowing the size.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
---
hw/arm/boot.c | 2 +-
hw/core/loader.c | 4 ++--
include/hw/loader.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 68fe8654e6..b44bea8a82 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -857,7 +857,7 @@ static uint64_t load_aarch64_image(const char *filename,
hwaddr mem_base,
hwaddr kernel_load_offset = KERNEL64_LOAD_ADDR;
uint64_t kernel_size = 0;
uint8_t *buffer;
- int size;
+ ssize_t size;
/* On aarch64, it's the bootloader's job to uncompress the kernel. */
size = load_image_gzipped_buffer(filename, LOAD_IMAGE_MAX_GUNZIP_BYTES,
diff --git a/hw/core/loader.c b/hw/core/loader.c
index c0407e2d0d..4dfdb027ee 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -886,11 +886,11 @@ struct linux_efi_zboot_header {
*
* If the image is not a Linux EFI zboot image, do nothing and return success.
*/
-ssize_t unpack_efi_zboot_image(uint8_t **buffer, int *size)
+ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size)
{
const struct linux_efi_zboot_header *header;
uint8_t *data = NULL;
- int ploff, plsize;
+ ssize_t ploff, plsize;
ssize_t bytes;
/* ignore if this is too small to be a EFI zboot image */
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 7f6d06b956..8985046be4 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -101,7 +101,7 @@ ssize_t load_image_gzipped_buffer(const char *filename,
uint64_t max_sz,
* Returns the size of the decompressed payload if decompression was performed
* successfully.
*/
-ssize_t unpack_efi_zboot_image(uint8_t **buffer, int *size);
+ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size);
#define ELF_LOAD_FAILED -1
#define ELF_LOAD_NOT_ELF -2
--
2.43.5
- [PULL 0/6] loongarch-to-apply queue, Bibo Mao, 2025/01/09
- [PULL 6/6] hw/intc/loongarch_extioi: Add irq routing support from physical id, Bibo Mao, 2025/01/09
- [PULL 1/6] hw/core/loader: Use ssize_t for efi zboot unpacker,
Bibo Mao <=
- [PULL 4/6] hw/intc/loongarch_extioi: Get cpu number from possible_cpu_arch_ids, Bibo Mao, 2025/01/09
- [PULL 5/6] hw/intc/loongarch_extioi: Remove num-cpu property, Bibo Mao, 2025/01/09
- [PULL 2/6] hw/loongarch/boot: Support Linux raw boot image, Bibo Mao, 2025/01/09
- [PULL 3/6] target/loongarch: Only support 64bit pte width, Bibo Mao, 2025/01/09
- Re: [PULL 0/6] loongarch-to-apply queue, Stefan Hajnoczi, 2025/01/09