From 301d143ea42c024f22b673b69c72a4cb3c8d151f Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 14 Sep 2016 01:23:08 +0200 Subject: [PATCH] elf,section: Fixed section code interpreting all empty names as the current executable This was causing crashes with eglibc which visits the loaded vdso with an empty dlpi_name. --- src/compat/section-elf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compat/section-elf.c b/src/compat/section-elf.c index 5c50a51..d08378a 100644 --- a/src/compat/section-elf.c +++ b/src/compat/section-elf.c @@ -142,7 +142,7 @@ static int open_module(const char *name, struct mod_handle *mod) { int fd; - if (!name[0]) + if (!name) fd = open_self(); else fd = open(name, O_RDONLY); @@ -219,6 +219,7 @@ struct callback { struct cri_section *sect; size_t size; size_t i; + size_t libnum; }; static int section_getaddr(struct dl_phdr_info *info, @@ -227,7 +228,10 @@ static int section_getaddr(struct dl_phdr_info *info, struct callback *ctx = data; struct mod_handle mod; - if (!open_module(info->dlpi_name, &mod)) + size_t libnum = ctx->libnum++; + + /* a libnum of 0 means the current executable */ + if (!open_module(libnum ? info->dlpi_name : NULL, &mod)) return 0; struct cri_section sect;