From: Roland McGrath Date: Mon, 7 Jan 2013 21:01:10 +0000 (-0800) Subject: elf_getarsym: Use memcpy instead of pointer dereference so as not to assume the field... X-Git-Tag: elfutils-0.156~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99d9db00b886b29b961b63d94424321be3ddfca5;p=thirdparty%2Felfutils.git elf_getarsym: Use memcpy instead of pointer dereference so as not to assume the field is naturally aligned. Signed-off-by: Roland McGrath --- diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 4a9e35810..23e1a8674 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2013-01-07 Roland McGrath + + * elf_getarsym.c (read_number_entries): Use memcpy instead of pointer + dereference so as not to assume the field is naturally aligned. + 2012-09-17 Petr Machata * elf.h: Update from glibc. diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c index 9e0f4c2bb..ffdd8ada0 100644 --- a/libelf/elf_getarsym.c +++ b/libelf/elf_getarsym.c @@ -57,7 +57,9 @@ read_number_entries (uint64_t *nump, Elf *elf, size_t *offp, bool index64_p) size_t w = index64_p ? 8 : 4; if (elf->map_address != NULL) - u = *(union u *) (elf->map_address + *offp); + /* Use memcpy instead of pointer dereference so as not to assume the + field is naturally aligned within the file. */ + memcpy (&u, elf->map_address + *offp, sizeof u); else if ((size_t) pread_retry (elf->fildes, &u, w, *offp) != w) return -1;