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