From 4bea58f5d62195a3d680f69ef74c836bd0653e95 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 18 Mar 2023 12:13:42 +0000 Subject: [PATCH] file: Pass Dyn tag to the callback function Some values are not considered to be strings. Signed-off-by: Michael Tremer --- src/libpakfire/file.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index d8034b6ab..10cd8439a 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -1745,11 +1745,13 @@ static int pakfire_file_get_elf_type(struct pakfire_file* file) { } static int pakfire_file_elf_dyn_walk(struct pakfire_file* file, Elf* elf, - int (*callback)(struct pakfire_file* file, Elf64_Word key, const char* value, void* data), + int (*callback)(struct pakfire_file* file, + Elf* elf, const GElf_Shdr* shdr, const GElf_Dyn* dyn, void* data), void* data) { Elf_Scn* dynamic = NULL; GElf_Shdr shdr; Elf_Data* elf_data = NULL; + GElf_Dyn dyn; int r; // Find the dynamic linking information @@ -1759,20 +1761,14 @@ static int pakfire_file_elf_dyn_walk(struct pakfire_file* file, Elf* elf, return 1; } - GElf_Dyn dyn; - const char* value = NULL; - // Walk through all entries... for (unsigned int i = 0; ; i++) { // Fetch the next entry if (!gelf_getdyn(elf_data, i, &dyn)) break; - // Fetch the value - value = elf_strptr(elf, shdr.sh_link, dyn.d_un.d_val); - // Call the callback - r = callback(file, dyn.d_tag, value, data); + r = callback(file, elf, &shdr, &dyn, data); if (r) return r; } @@ -1975,28 +1971,34 @@ static int __pakfire_file_check_partially_relro( } // This file does not seem to have PT_GNU_RELRO set - file->issues |= PAKFIRE_FILE_NO_PARTIALLY_RELRO; + file->issues |= PAKFIRE_FILE_NO_RELRO; return 0; } static int pakfire_file_check_relro(struct pakfire_file* file) { - return pakfire_file_open_elf(file, __pakfire_file_check_partially_relro, NULL); + return pakfire_file_open_elf(file, __pakfire_file_check_relro, NULL); } /* RPATH/RUNPATH */ static int __pakfire_file_process_runpath(struct pakfire_file* file, - Elf64_Word key, const char* value, void* data) { + Elf* elf, const GElf_Shdr* shdr, const GElf_Dyn* dyn, void* data) { + const char* value = NULL; const char* runpath = NULL; char buffer[PATH_MAX]; char* p = NULL; int r; - switch (key) { + switch (dyn->d_tag) { case DT_RUNPATH: case DT_RPATH: + // Fetch the value + value = elf_strptr(elf, shdr->sh_link, dyn->d_un.d_val); + if (!value) + return 1; + DEBUG(file->pakfire, "%s has a RUNPATH: %s\n", file->path, value); // Copy the value into a buffer we can modify -- 2.47.3