mvadkert / rpms / file

Forked from rpms/file 5 years ago
Clone
Blob Blame History Raw
From 9ec8a9d418059f6a2db0a8b5dd9c3242b4ab8b0a Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 26 Jul 2018 17:39:05 +0200
Subject: [PATCH] magic: fix printing of details about ELF binaries

This commit fixes a regression introduced by the following commit:
https://github.com/file/file/commit/e2adab14

Without this patch:
/usr/bin/curl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV)
/usr/bin/true: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=57291d41021b27733e8eb00ee1e561a98c11e2d2, stripped

With this patch:
/usr/bin/curl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=fd7ce380cd8dff1f52c1a4c1f3d8635cb20dda23, stripped, too many notes (256)
/usr/bin/true: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=57291d41021b27733e8eb00ee1e561a98c11e2d2, stripped
---
 src/funcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/funcs.c b/src/funcs.c
index 0bf92fe1..4ddf5afe 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -268,7 +268,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__u
 
 		rv = file_tryelf(ms, &b);
 		rbuf = file_pop_buffer(ms, pb);
-		if (rv != 1) {
+		if (rv == -1) {
 			free(rbuf);
 			rbuf = NULL;
 		}
-- 
2.14.4