ia64/xen-unstable
changeset 13520:5d08bf268f92
[TOOLS] Avoid void* arithmetic when parsing elf notes.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Fri Jan 19 15:05:20 2007 +0000 (2007-01-19) |
parents | 1e5ad8ccb286 |
children | 374688d2db78 |
files | tools/libxc/xc_load_elf.c tools/xcutils/readnotes.c |
line diff
1.1 --- a/tools/libxc/xc_load_elf.c Fri Jan 19 15:03:02 2007 +0000 1.2 +++ b/tools/libxc/xc_load_elf.c Fri Jan 19 15:05:20 2007 +0000 1.3 @@ -177,7 +177,7 @@ static unsigned long long xen_guest_nume 1.4 /* 1.5 * Interface to the Xen ELF notes. 1.6 */ 1.7 -#define ELFNOTE_NAME(_n_) ((const void*)(_n_) + sizeof(*(_n_))) 1.8 +#define ELFNOTE_NAME(_n_) ((const char*)(_n_) + sizeof(*(_n_))) 1.9 #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3)) 1.10 #define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3)) 1.11 1.12 @@ -190,7 +190,7 @@ static int is_xen_elfnote_section(const 1.13 1.14 for ( note = (const Elf_Note *)(image + shdr->sh_offset); 1.15 note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size); 1.16 - note = ELFNOTE_NEXT(note) ) 1.17 + note = (const Elf_Note *)ELFNOTE_NEXT(note) ) 1.18 { 1.19 if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) ) 1.20 return 1; 1.21 @@ -209,7 +209,7 @@ static const Elf_Note *xen_elfnote_looku 1.22 1.23 for ( note = (const Elf_Note *)dsi->__elfnote_section; 1.24 note < (const Elf_Note *)dsi->__elfnote_section_end; 1.25 - note = ELFNOTE_NEXT(note) ) 1.26 + note = (const Elf_Note *)ELFNOTE_NEXT(note) ) 1.27 { 1.28 if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) ) 1.29 continue; 1.30 @@ -338,9 +338,9 @@ static int parseelfimage(const char *ima 1.31 image + ehdr->e_shoff + (h*ehdr->e_shentsize)); 1.32 if ( !is_xen_elfnote_section(image, shdr) ) 1.33 continue; 1.34 - dsi->__elfnote_section = (const void *)image + shdr->sh_offset; 1.35 + dsi->__elfnote_section = (const char *)image + shdr->sh_offset; 1.36 dsi->__elfnote_section_end = 1.37 - (const void *)image + shdr->sh_offset + shdr->sh_size; 1.38 + (const char *)image + shdr->sh_offset + shdr->sh_size; 1.39 break; 1.40 } 1.41
2.1 --- a/tools/xcutils/readnotes.c Fri Jan 19 15:03:02 2007 +0000 2.2 +++ b/tools/xcutils/readnotes.c Fri Jan 19 15:05:20 2007 +0000 2.3 @@ -13,7 +13,7 @@ 2.4 2.5 #include <xen/elfnote.h> 2.6 2.7 -#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_))) 2.8 +#define ELFNOTE_NAME(_n_) ((char*)(_n_) + sizeof(*(_n_))) 2.9 #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->n_namesz+3)&~3)) 2.10 #define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->n_descsz+3)&~3)) 2.11