From f8ba1437114e408de0f66efb272fdc1de986017a Mon Sep 17 00:00:00 2001 From: Vincent Mihalkovic Date: Mon, 6 Feb 2023 14:39:58 +0100 Subject: [PATCH] We need to process the dynamic section so that we can set $x for mime. 9ffbd485ba4647827c4bdacf3a2de690f6765b0c --- src/readelf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/readelf.c b/src/readelf.c index cdc211f..94cdaca 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1273,6 +1273,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilities */ char name[50]; ssize_t namesize; + if (ms->flags & MAGIC_MIME) + return 0; if (size != xsh_sizeof) { if (file_printf(ms, ", corrupted section header size") == -1) @@ -1622,6 +1624,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, break; case PT_INTERP: + if (ms->flags & MAGIC_MIME) + continue; if (bufsize && nbuf[0]) { nbuf[bufsize - 1] = '\0'; memcpy(interp, nbuf, bufsize); @@ -1629,6 +1633,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, strlcpy(interp, "*empty*", sizeof(interp)); break; case PT_NOTE: + if (ms->flags & MAGIC_MIME) + return 0; /* * This is a PT_NOTE section; loop through all the notes * in the section. @@ -1645,9 +1651,13 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, } break; default: + if (ms->flags & MAGIC_MIME) + continue; break; } } + if (ms->flags & MAGIC_MIME) + return 0; if (file_printf(ms, ", %s linked", linking_style) == -1) return -1; @@ -1678,7 +1688,7 @@ file_tryelf(struct magic_set *ms, const struct buffer *b) Elf64_Ehdr elf64hdr; uint16_t type, phnum, shnum, notecount; - if (ms->flags & (MAGIC_MIME|MAGIC_APPLE|MAGIC_EXTENSION)) + if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) return 0; /* * ELF executables have multiple section headers in arbitrary -- 2.39.1