From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 22363138D11 for ; Mon, 13 Jul 2015 09:15:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D76ABE08F4; Mon, 13 Jul 2015 09:15:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2028BE08F4 for ; Mon, 13 Jul 2015 09:15:00 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F14E6340973 for ; Mon, 13 Jul 2015 09:14:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A3B6A905 for ; Mon, 13 Jul 2015 09:14:57 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1436777953.9daf7217a29e8542ad80672a3b82ae1b8c497321.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: paxinc.c paxinc.h scanelf.c scanmacho.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 9daf7217a29e8542ad80672a3b82ae1b8c497321 X-VCS-Branch: master Date: Mon, 13 Jul 2015 09:14:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: f6ce8ff4-cdaf-47cc-84b5-b1c228809390 X-Archives-Hash: 901b3af3849ef28794bb47e86ec756bb commit: 9daf7217a29e8542ad80672a3b82ae1b8c497321 Author: Mike Frysinger gentoo org> AuthorDate: Mon Jul 13 08:59:13 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Mon Jul 13 08:59:13 2015 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=9daf7217 scanelf: do not warn about invalid archive entries by default It's not uncommon for embedded toolchains or random targets to create their own spin on the archive format. Rather than complain about all of these by default, put it behind the -v flag. It's not like people can do anything about this normally anyways. URL: https://bugs.gentoo.org/428464 paxinc.c | 12 ++++++++---- paxinc.h | 5 +++-- scanelf.c | 2 +- scanmacho.c | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/paxinc.c b/paxinc.c index f2ce3c5..64a7f3b 100644 --- a/paxinc.c +++ b/paxinc.c @@ -17,7 +17,7 @@ char do_reverse_endian; #define AR_MAGIC "!" #define AR_MAGIC_SIZE (sizeof(AR_MAGIC)-1) /* dont count null byte */ -archive_handle *ar_open_fd(const char *filename, int fd) +archive_handle *ar_open_fd(const char *filename, int fd, bool verbose) { static archive_handle ret; char buf[AR_MAGIC_SIZE]; @@ -26,6 +26,7 @@ archive_handle *ar_open_fd(const char *filename, int fd) ret.fd = fd; ret.skip = 0; ret.extfn = NULL; + ret.verbose = verbose; if (read(ret.fd, buf, AR_MAGIC_SIZE) != AR_MAGIC_SIZE) return NULL; @@ -34,7 +35,7 @@ archive_handle *ar_open_fd(const char *filename, int fd) return &ret; } -archive_handle *ar_open(const char *filename) +archive_handle *ar_open(const char *filename, bool verbose) { int fd; archive_handle *ret; @@ -42,7 +43,7 @@ archive_handle *ar_open(const char *filename) if ((fd=open(filename, O_RDONLY)) == -1) errp("%s: could not open", filename); - ret = ar_open_fd(filename, fd); + ret = ar_open_fd(filename, fd, verbose); if (ret == NULL) close(fd); @@ -76,7 +77,10 @@ close_and_ret: } if ((ret.buf.formatted.magic[0] != '`') || (ret.buf.formatted.magic[1] != '\n')) { - warn("%s: invalid ar entry", ar->filename); + /* When dealing with corrupt or random embedded cross-compilers, they might + * be abusing the archive format; only complain when in verbose mode. */ + if (ar->verbose) + warn("%s: invalid ar entry", ar->filename); goto close_and_ret; } diff --git a/paxinc.h b/paxinc.h index 003877d..0a8e08a 100644 --- a/paxinc.h +++ b/paxinc.h @@ -37,6 +37,7 @@ typedef struct { const char *filename; size_t skip; char *extfn; + bool verbose; } archive_handle; #else typedef void archive_handle; @@ -63,8 +64,8 @@ typedef struct { } buf; #endif } archive_member; -archive_handle *ar_open_fd(const char *filename, int fd); -archive_handle *ar_open(const char *filename); +archive_handle *ar_open_fd(const char *filename, int fd, bool verbose); +archive_handle *ar_open(const char *filename, bool verbose); archive_member *ar_next(archive_handle *); const char *strfileperms(const char *fname); diff --git a/scanelf.c b/scanelf.c index 7219f1c..82ab626 100644 --- a/scanelf.c +++ b/scanelf.c @@ -1717,7 +1717,7 @@ static int scanelf_archive(const char *filename, int fd, size_t len) char *ar_buffer; elfobj *elf; - ar = ar_open_fd(filename, fd); + ar = ar_open_fd(filename, fd, be_verbose); if (ar == NULL) return 1; diff --git a/scanmacho.c b/scanmacho.c index a36aed4..f8c4d89 100644 --- a/scanmacho.c +++ b/scanmacho.c @@ -383,7 +383,7 @@ static int scanmacho_archive(const char *filename, int fd, size_t len) fatobj *fobj; fatobj *walk; - ar = ar_open_fd(filename, fd); + ar = ar_open_fd(filename, fd, be_verbose); if (ar == NULL) return 1;