1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-14 04:18:11 +01:00

ppc: return UNW_INVALID instead of assert on unaligned addresses

In src/ppc64/Gstep.c, we use fetch32 to fetch instruction from the
inferior process. In  UNW_REMOTE case, fetch32 asserts that the
address we are fetching from is aligned.

But if the inferior is corrupt, we can get unaligned IP, and hit the assert.

Attached patch removes the assert, and makes fetch32 (and fetch16)
return -UNW_EINVAL instead.
This commit is contained in:
Paul Pluzhnikov 2017-04-05 11:12:58 -07:00 committed by Dave Watson
parent 982e934951
commit 7a7833ee0a

View file

@ -74,7 +74,8 @@ fetch16 (unw_addr_space_t as, unw_accessors_t *a,
unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
int ret;
assert ((off & 0x1) == 0);
if ((off & 0x1) == 0)
return -UNW_EINVAL;
*addr += 2;
@ -96,7 +97,8 @@ fetch32 (unw_addr_space_t as, unw_accessors_t *a,
unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
int ret;
assert ((off & 0x3) == 0);
if ((off & 0x3) == 0)
return -UNW_EINVAL;
*addr += 4;