File fix_of_backport_PR-62.patch of Package file.14657

Subject: Fix broken backport of the fix of PR-62
From: Werner Fink <werner@suse.de>

The backport of the fix for PR-62 with patch
0002-PR-62-spinpx-limit-size-of-file_printable.patch
broke the oputput of the interpreter string

---
 src/readelf.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- src/readelf.c
+++ src/readelf.c	2020-09-18 14:06:18.335832113 +0200
@@ -1243,9 +1243,9 @@ dophn_exec(struct magic_set *ms, int cla
 	Elf32_Phdr ph32;
 	Elf64_Phdr ph64;
 	const char *linking_style = "statically";
-	const char *interp = "";
 	unsigned char nbuf[BUFSIZ];
 	char ibuf[BUFSIZ];
+	char interp[BUFSIZ];
 	ssize_t bufsize;
 	size_t offset, align, len;
 	
@@ -1255,6 +1255,7 @@ dophn_exec(struct magic_set *ms, int cla
 		return 0;
 	}
 
+	interp[0] = '\0';
   	for ( ; num; num--) {
 		if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) {
 			file_badread(ms);
@@ -1304,9 +1305,9 @@ dophn_exec(struct magic_set *ms, int cla
 		case PT_INTERP:
 			if (bufsize && nbuf[0]) {
 				nbuf[bufsize - 1] = '\0';
-				interp = (const char *)nbuf;
+				memcpy(interp, nbuf, CAST(size_t, bufsize));
 			} else
-				interp = "*empty*";
+				strlcpy(interp, "*empty*", sizeof(interp));
 			break;
 		case PT_NOTE:
 			/*
openSUSE Build Service is sponsored by