From 71a68fc29f30bf8646064a213955c2b22dfca0fd Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Sat, 29 Dec 2018 23:45:23 +0100 Subject: [PATCH] Fix a segfault in PARSE_ELF on binaries generated by clang and lld The symbols we search for are of type object (`__*_hook`) or func (`__libc_*`), hence we should limit the condition to those. Closes: https://bugs.gentoo.org/672918 Signed-Off-By: Dennis Schridde --- libsandbox/wrapper-funcs/__wrapper_exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c b/libsandbox/wrapper-funcs/__wrapper_exec.c index 226c0c0..e0070e5 100644 --- a/libsandbox/wrapper-funcs/__wrapper_exec.c +++ b/libsandbox/wrapper-funcs/__wrapper_exec.c @@ -165,7 +165,9 @@ static bool sb_check_exec(const char *filename, char *const argv[]) \ while (sym < symend) { \ char *symname = (void *)(elf + stroff + sym->st_name); \ - if (ELF##n##_ST_VISIBILITY(sym->st_other) == STV_DEFAULT && \ + if ((ELF##n##_ST_TYPE(sym->st_info) == STT_OBJECT || \ + ELF##n##_ST_TYPE(sym->st_info) == STT_FUNC) && \ + ELF##n##_ST_VISIBILITY(sym->st_other) == STV_DEFAULT && \ sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE && \ sym->st_name && \ /* Minor optimization to avoid strcmp. */ \ -- 2.20.1