diff options
author | Mark Wielaard <mark@klomp.org> | 2017-03-24 14:10:26 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2017-04-03 23:47:59 +0200 |
commit | b0b58c5e0b34e54194aa042f2310af58ee7de603 (patch) | |
tree | 833f7fb0c98218a3af8450f8d5171e320b4f20d3 /libdwfl | |
parent | 9d84fdd78705d7a1b9947a9f4ca77fbccdd76d4a (diff) |
Use the empty string for note names with zero size (without any data).
ELF notes can have a zero sized name. In which case there is no data at
all (so also no zero terminator). Make sure to use the empty string for
such notes if the code does not otherwise explicitly check n_namesz.
https://sourceware.org/bugzilla/show_bug.cgi?id=21300
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r-- | libdwfl/ChangeLog | 6 | ||||
-rw-r--r-- | libdwfl/linux-core-attach.c | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 4c9f4f6a..ede6d471 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2017-03-24 Mark Wielaard <mark@klomp.org> + + * linux-core-attach.c (core_next_thread): If n_namesz == 0 then + the note name data is the empty string. + (dwfl_core_file_attach): Likewise. + 2017-02-15 Ulf Hermann <ulf.hermann@qt.io> * linux-kernel-modules.c: Include system.h. diff --git a/libdwfl/linux-core-attach.c b/libdwfl/linux-core-attach.c index 93d0e46e..f82ed032 100644 --- a/libdwfl/linux-core-attach.c +++ b/libdwfl/linux-core-attach.c @@ -125,7 +125,8 @@ core_next_thread (Dwfl *dwfl __attribute__ ((unused)), void *dwfl_arg, &desc_offset)) > 0) { /* Do not check NAME for now, help broken Linux kernels. */ - const char *name = note_data->d_buf + name_offset; + const char *name = (nhdr.n_namesz == 0 + ? "" : note_data->d_buf + name_offset); const char *desc = note_data->d_buf + desc_offset; GElf_Word regs_offset; size_t nregloc; @@ -178,7 +179,8 @@ core_set_initial_registers (Dwfl_Thread *thread, void *thread_arg_voidp) /* __libdwfl_attach_state_for_core already verified the note is there. */ assert (getnote_err != 0); /* Do not check NAME for now, help broken Linux kernels. */ - const char *name = note_data->d_buf + name_offset; + const char *name = (nhdr.n_namesz == 0 + ? "" : note_data->d_buf + name_offset); const char *desc = note_data->d_buf + desc_offset; GElf_Word regs_offset; size_t nregloc; @@ -367,7 +369,8 @@ dwfl_core_file_attach (Dwfl *dwfl, Elf *core) &nhdr, &name_offset, &desc_offset)) > 0) { /* Do not check NAME for now, help broken Linux kernels. */ - const char *name = note_data->d_buf + name_offset; + const char *name = (nhdr.n_namesz == 0 + ? "" : note_data->d_buf + name_offset); const char *desc = note_data->d_buf + desc_offset; GElf_Word regs_offset; size_t nregloc; |