diff options
author | Mike Frysinger <vapier@gentoo.org> | 2024-01-25 22:46:42 -0500 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-08-09 11:06:16 +0100 |
commit | d1d12246b7c5df3e20b062e536da9b4e639a4a66 (patch) | |
tree | 2b88e61dbd33b574fd248ff15da2f0a0bb1c5bf0 | |
parent | meson: avoid using replace() to not unnecessarily bump meson >= 0.58.0 (diff) | |
download | pax-utils-d1d12246b7c5df3e20b062e536da9b4e639a4a66.tar.gz pax-utils-d1d12246b7c5df3e20b062e536da9b4e639a4a66.tar.bz2 pax-utils-d1d12246b7c5df3e20b062e536da9b4e639a4a66.zip |
dumpelf: check dyn pointer before DT_NULL check too
We were checking the pointer before dumping it, but missed the
DT_NULL check in the overall while loop.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
(cherry picked from commit 7b37c40d0409d79a925b71135e9de96343096ce8)
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | dumpelf.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -125,13 +125,17 @@ static void dumpelf(const elfobj *elf, size_t file_cnt) if (elf->elf_class == ELFCLASS ## B) { \ const Elf ## B ## _Phdr *phdr = phdr_dynamic_void; \ const Elf ## B ## _Dyn *dyn = elf->vdata + EGET(phdr->p_offset); \ + if ((void *)dyn >= elf->data_end - sizeof(*dyn)) { \ + printf(" /* invalid dynamic tags ! */ "); \ + goto break_out_dyn; \ + } \ i = 0; \ do { \ + dump_dyn(elf, dyn++, i++); \ if ((void *)dyn >= elf->data_end - sizeof(*dyn)) { \ printf(" /* invalid dynamic tags ! */ "); \ break; \ } \ - dump_dyn(elf, dyn++, i++); \ } while (EGET(dyn->d_tag) != DT_NULL); \ } DUMP_DYNS(32) @@ -139,6 +143,7 @@ static void dumpelf(const elfobj *elf, size_t file_cnt) } else { printf(" /* no dynamic tags ! */ "); } + break_out_dyn: printf("};\n"); } |