[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] elf-loader: Fix truncation warni
From: |
Thomas Huth |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity |
Date: |
Mon, 16 Mar 2015 12:50:20 +0100 |
On Sat, 14 Mar 2015 09:37:08 +0100
Stefan Weil <address@hidden> wrote:
> Coverity reports a truncation due to cast operation on operand
> reltab->sh_size from 64 bits to 32 bits for calls of load_at.
>
> Fix the types of the function arguments to match their use in
> function load_at: the offset is used for lseek which takes an
> off_t parameter, the size is used for g_malloc and read.
>
> Signed-off-by: Stefan Weil <address@hidden>
> ---
> hw/core/loader.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 76d8aca..d4c441f 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -267,7 +267,7 @@ int load_aout(const char *filename, hwaddr addr, int
> max_sz,
>
> /* ELF loader */
>
> -static void *load_at(int fd, int offset, int size)
> +static void *load_at(int fd, off_t offset, size_t size)
> {
> void *ptr;
> if (lseek(fd, offset, SEEK_SET) < 0)
Sounds reasonable.
Reviewed-by: Thomas Huth <address@hidden>