]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elf_getarsym: Handle unaligned data in archive index.
authorRoland McGrath <roland@hack.frob.com>
Mon, 7 Jan 2013 22:30:54 +0000 (14:30 -0800)
committerRoland McGrath <roland@hack.frob.com>
Mon, 7 Jan 2013 22:30:54 +0000 (14:30 -0800)
libelf/ChangeLog
libelf/elf_getarsym.c

index 23e1a8674df6b6bdf591dfcf24f92875efcbec13..674a720cdcbfffa937f14f5af288fddea5ca31ab 100644 (file)
@@ -1,5 +1,8 @@
 2013-01-07  Roland McGrath  <roland@hack.frob.com>
 
+       * elf_getarsym.c (elf_getarsym): Copy FILE_DATA into stack space if it
+       would be unaligned and !ALLOW_UNALIGNED.
+
        * elf_getarsym.c (read_number_entries): Use memcpy instead of pointer
        dereference so as not to assume the field is naturally aligned.
 
index ffdd8ada05b91ff36a6f10a86a1e660eb3b2d012..d0bb28a939827e2f10741ce686cd17d23bc56261 100644 (file)
@@ -240,6 +240,9 @@ elf_getarsym (elf, ptr)
          else
            {
              file_data = (void *) (elf->map_address + off);
+             if (!ALLOW_UNALIGNED
+                 && ((uintptr_t) file_data & -(uintptr_t) n) != 0)
+               file_data = memcpy (alloca (sz), elf->map_address + off, sz);
              str_data = (char *) (elf->map_address + off + sz);
            }