mirror of
https://github.com/qemu/qemu.git
synced 2025-08-15 13:47:03 +00:00
hw/core/loader: Use ssize_t for efi zboot unpacker
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>
This commit is contained in:
parent
3f8bcbba3b
commit
e3526d0fd7
@ -857,7 +857,7 @@ static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base,
|
|||||||
hwaddr kernel_load_offset = KERNEL64_LOAD_ADDR;
|
hwaddr kernel_load_offset = KERNEL64_LOAD_ADDR;
|
||||||
uint64_t kernel_size = 0;
|
uint64_t kernel_size = 0;
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
int size;
|
ssize_t size;
|
||||||
|
|
||||||
/* On aarch64, it's the bootloader's job to uncompress the kernel. */
|
/* On aarch64, it's the bootloader's job to uncompress the kernel. */
|
||||||
size = load_image_gzipped_buffer(filename, LOAD_IMAGE_MAX_GUNZIP_BYTES,
|
size = load_image_gzipped_buffer(filename, LOAD_IMAGE_MAX_GUNZIP_BYTES,
|
||||||
|
@ -886,11 +886,11 @@ struct linux_efi_zboot_header {
|
|||||||
*
|
*
|
||||||
* If the image is not a Linux EFI zboot image, do nothing and return success.
|
* 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;
|
const struct linux_efi_zboot_header *header;
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
int ploff, plsize;
|
ssize_t ploff, plsize;
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
|
|
||||||
/* ignore if this is too small to be a EFI zboot image */
|
/* ignore if this is too small to be a EFI zboot image */
|
||||||
|
@ -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
|
* Returns the size of the decompressed payload if decompression was performed
|
||||||
* successfully.
|
* 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_FAILED -1
|
||||||
#define ELF_LOAD_NOT_ELF -2
|
#define ELF_LOAD_NOT_ELF -2
|
||||||
|
Loading…
Reference in New Issue
Block a user