qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity
@ 2015-03-14  8:37 Stefan Weil
  2015-03-16 11:50 ` Thomas Huth
  2015-03-19  8:37 ` Michael Tokarev
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Weil @ 2015-03-14  8:37 UTC (permalink / raw)
  To: QEMU Trivial; +Cc: Stefan Weil, QEMU Developer

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 <sw@weilnetz.de>
---
 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)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity
  2015-03-14  8:37 [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity Stefan Weil
@ 2015-03-16 11:50 ` Thomas Huth
  2015-03-19  8:37 ` Michael Tokarev
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2015-03-16 11:50 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Trivial, QEMU Developer

On Sat, 14 Mar 2015 09:37:08 +0100
Stefan Weil <sw@weilnetz.de> 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 <sw@weilnetz.de>
> ---
>  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 <thuth@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity
  2015-03-14  8:37 [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity Stefan Weil
  2015-03-16 11:50 ` Thomas Huth
@ 2015-03-19  8:37 ` Michael Tokarev
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2015-03-19  8:37 UTC (permalink / raw)
  To: Stefan Weil, QEMU Trivial; +Cc: QEMU Developer

Applied to -trivial, thanks!

/mjt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-19  8:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-14  8:37 [Qemu-devel] [PATCH] elf-loader: Fix truncation warning from coverity Stefan Weil
2015-03-16 11:50 ` Thomas Huth
2015-03-19  8:37 ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).