1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 03:53:43 +01:00

elfxx: store elf image pointer and size after mapping image

If loading debug link is not successful, the initial NULL pointer for
ei->image will eventually be restored, causing segfault during a later
call to valid_object.

Move populating the prev_image and prev_size to after elf_map_image() to
fix this.

Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
This commit is contained in:
Hans-Christian Noren Egtvedt 2017-11-08 11:34:35 +01:00 committed by Dave Watson
parent f248ac0c6e
commit 46c336d18f

View file

@ -386,8 +386,8 @@ elf_w (load_debuglink) (const char* file, struct elf_image *ei, int is_local)
{
int ret;
Elf_W (Shdr) *shdr;
Elf_W (Ehdr) *prev_image = ei->image;
off_t prev_size = ei->size;
Elf_W (Ehdr) *prev_image;
off_t prev_size;
if (!ei->image)
{
@ -396,6 +396,9 @@ elf_w (load_debuglink) (const char* file, struct elf_image *ei, int is_local)
return ret;
}
prev_image = ei->image;
prev_size = ei->size;
/* Ignore separate debug files which contain a .gnu_debuglink section. */
if (is_local == -1) {
return 0;