]> xenbits.xensource.com Git - xen.git/commitdiff
libelf: section index 0 is special
authorJan Beulich <jbeulich@suse.com>
Wed, 18 Jan 2017 09:08:22 +0000 (10:08 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 18 Jan 2017 09:08:22 +0000 (10:08 +0100)
When iterating over sections, table entry zero needs to be ignored.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: 41fe9cabf29ea15c1f8edee49326dfde705013d3
master date: 2016-12-07 13:52:35 +0100

xen/common/libelf/libelf-dominfo.c
xen/common/libelf/libelf-loader.c
xen/common/libelf/libelf-tools.c

index ec6944940ee4e652b525151d1a249d7ba30888e3..845397c2b9da0763325a6531f8399e82a2bc5dc4 100644 (file)
@@ -540,7 +540,7 @@ elf_errorstatus elf_xen_parse(struct elf_binary *elf,
     if ( xen_elfnotes == 0 )
     {
         count = elf_shdr_count(elf);
-        for ( i = 0; i < count; i++ )
+        for ( i = 1; i < count; i++ )
         {
             shdr = elf_shdr_by_index(elf, i);
             if ( !elf_access_ok(elf, ELF_HANDLE_PTRVAL(shdr), 1) )
index bc1f87b751db46285693ce862af747f85b4be9a6..e4b46f25dfacd9464f6c923b26b31bb070e39a20 100644 (file)
@@ -72,7 +72,7 @@ elf_errorstatus elf_init(struct elf_binary *elf, const char *image_input, size_t
 
     /* Find symbol table and symbol string table. */
     count = elf_shdr_count(elf);
-    for ( i = 0; i < count; i++ )
+    for ( i = 1; i < count; i++ )
     {
         shdr = elf_shdr_by_index(elf, i);
         if ( !elf_access_ok(elf, ELF_HANDLE_PTRVAL(shdr), 1) )
index e73e729fff03215565e0a2786b0dca25ecaffbb8..0197b858190c134d152c78d2a36ea29890e7bd99 100644 (file)
@@ -153,7 +153,7 @@ ELF_HANDLE_DECL(elf_shdr) elf_shdr_by_name(struct elf_binary *elf, const char *n
     const char *sname;
     unsigned i;
 
-    for ( i = 0; i < count; i++ )
+    for ( i = 1; i < count; i++ )
     {
         shdr = elf_shdr_by_index(elf, i);
         if ( !elf_access_ok(elf, ELF_HANDLE_PTRVAL(shdr), 1) )