From 6722a667bbeb003258b35e0ee773fef9abcbdef0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 7 Jan 2013 14:30:54 -0800 Subject: [PATCH] elf_getarsym: Handle unaligned data in archive index. --- libelf/ChangeLog | 3 +++ libelf/elf_getarsym.c | 3 +++ 2 files changed, 6 insertions(+) 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); } -- 2.47.2