From: Roland McGrath Date: Mon, 7 Jan 2013 22:30:54 +0000 (-0800) Subject: elf_getarsym: Handle unaligned data in archive index. X-Git-Tag: elfutils-0.156~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6722a667bbeb003258b35e0ee773fef9abcbdef0;p=thirdparty%2Felfutils.git elf_getarsym: Handle unaligned data in archive index. --- diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 23e1a8674..674a720cd 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,5 +1,8 @@ 2013-01-07 Roland McGrath + * 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. diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c index ffdd8ada0..d0bb28a93 100644 --- a/libelf/elf_getarsym.c +++ b/libelf/elf_getarsym.c @@ -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); }