diff options
| author | Mark Wielaard <[email protected]> | 2016-08-12 11:36:10 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-08-15 09:58:18 +0200 |
| commit | b3a576d2d17efd75777b485c0b20a9a3cd43acb6 (patch) | |
| tree | ef1197768acc4716d5108b569a0a52de32c50d18 /libdwfl/link_map.c | |
| parent | e93f2d801fccbe5a4ffd71f07baed66453b8a56c (diff) | |
libdwfl: Fix assert and set in.d_size in dwfl_link_map_report.
When reading the phdrs from a core file segment fails we would try to read
them from the exec. This fallback path contained a faulty assert that the
requested size of the phdrs was still setup. But the core file reading
callback might have reset the d_size value to zero on error. So explicitly
set the number of bytes we want to read again instead of asserting the size.
https://bugzilla.redhat.com/show_bug.cgi?id=1365812
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdwfl/link_map.c')
| -rw-r--r-- | libdwfl/link_map.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 28d7382f..794668fc 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -1,5 +1,5 @@ /* Report modules by examining dynamic linker data structures. - Copyright (C) 2008-2015 Red Hat, Inc. + Copyright (C) 2008-2016 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -843,7 +843,10 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size, } off_t off = ehdr->e_phoff; assert (in.d_buf == NULL); - assert (in.d_size == phnum * phent); + /* Note this in the !in_ok path. That means memory_callback + failed. But the callback might still have reset the d_size + value (to zero). So explicitly set it here again. */ + in.d_size = phnum * phent; in.d_buf = malloc (in.d_size); if (unlikely (in.d_buf == NULL)) { |
