summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-12-18 02:01:37 +0100
committerMark Wielaard <mark@klomp.org>2021-12-18 02:23:44 +0100
commitb16ff8198f91714048faaaed2a9b4e6801293226 (patch)
tree59da18ee5d2599434dc0319b75890fa7689b353a /libdwfl
parentlibdwfl: Make sure there is at least one phdr (diff)
downloadelfutils-b16ff8198f91714048faaaed2a9b4e6801293226.tar.gz
elfutils-b16ff8198f91714048faaaed2a9b4e6801293226.tar.bz2
elfutils-b16ff8198f91714048faaaed2a9b4e6801293226.tar.xz
libdwfl: Make sure note data is properly aligned.
In dwfl_segment_report_module the note data might not be properly aligned. Check that it is before accessing the data directly. Otherwise convert data so it is properly aligned. Also fix NOTE_ALIGN4 and NOTE_ALIGN8 to work correctly with long types. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_segment_report_module.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 8760b1ef..f18a0c45 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,10 @@
12021-12-16 Mark Wielaard <mark@klomp.org> 12021-12-16 Mark Wielaard <mark@klomp.org>
2 2
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Check
4 note data is properly aligned.
5
62021-12-16 Mark Wielaard <mark@klomp.org>
7
3 * link_map.c (dwfl_link_map_report): Make sure phnum is non-zero. 8 * link_map.c (dwfl_link_map_report): Make sure phnum is non-zero.
4 9
52021-12-16 Mark Wielaard <mark@klomp.org> 102021-12-16 Mark Wielaard <mark@klomp.org>
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index f323929e..2263e3cc 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -517,7 +517,10 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
517 assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr)); 517 assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
518 518
519 void *notes; 519 void *notes;
520 if (ei_data == MY_ELFDATA) 520 if (ei_data == MY_ELFDATA
521 && (uintptr_t) data == (align == 8
522 ? NOTE_ALIGN8 ((uintptr_t) data)
523 : NOTE_ALIGN4 ((uintptr_t) data)))
521 notes = data; 524 notes = data;
522 else 525 else
523 { 526 {