elf-loader: Fix truncation warning from coverity
PATCH 1/1 elf-loader: Fix truncation warning from coverity
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.
--- hw/core/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/loader.c +1 -1
@@ -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 )
Signature · 1 line
1.7.10.4
Quoted 17 lines · On Sat, 14 Mar 2015 09:37:08 +0100 Stefan Weil <[email protected]> wrote:
Coverity reports a truncation due to cast operation on operand
reltab->sh_sizefrom 64 bits to 32 bits for calls ofload_at.Fix the types of the function arguments to match their use in function
load_at: the offset is used for lseek which takes anoff_tparameter, the size is used forg_mallocand read.Signed-off-by Stefan Weil <[email protected]>--- hw/core/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/core/loader.c +0
-0
hw/core/loader.c int load_aout(const char *filename, hwaddr addr, int max_sz, · line 273
Quoted 8 lines
hw/core/loader.c +1
-1@@ -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.
Michael Tokarev
AppliedApplied to -trivial, thanks!
/mjt