diff options
| author | Roland McGrath <[email protected]> | 2013-01-07 13:01:10 -0800 |
|---|---|---|
| committer | Roland McGrath <[email protected]> | 2013-01-07 13:01:10 -0800 |
| commit | 99d9db00b886b29b961b63d94424321be3ddfca5 (patch) | |
| tree | a23c65ca22f98989a502c2a822ab74a430d07fc8 | |
| parent | 00f758c2c1625a932456c17fd8c80fc904db3484 (diff) | |
elf_getarsym: Use memcpy instead of pointer dereference so as not to assume the field is naturally aligned.
Signed-off-by: Roland McGrath <[email protected]>
| -rw-r--r-- | libelf/ChangeLog | 5 | ||||
| -rw-r--r-- | libelf/elf_getarsym.c | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 4a9e3581..23e1a867 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2013-01-07 Roland McGrath <[email protected]> + + * 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 <[email protected]> * elf.h: Update from glibc. diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c index 9e0f4c2b..ffdd8ada 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; |
