mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-22 23:47:39 +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:
parent
982e934951
commit
7a7833ee0a
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue