diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-07-13 04:59:13 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-07-13 04:59:13 -0400 |
commit | 9daf7217a29e8542ad80672a3b82ae1b8c497321 (patch) | |
tree | 4604bbfc5b14b82d1cb3a0b07d21922cd907c470 | |
parent | scanelf: include filename/details in all ar related messages (diff) | |
download | pax-utils-9daf7217a29e8542ad80672a3b82ae1b8c497321.tar.gz pax-utils-9daf7217a29e8542ad80672a3b82ae1b8c497321.tar.bz2 pax-utils-9daf7217a29e8542ad80672a3b82ae1b8c497321.zip |
scanelf: do not warn about invalid archive entries by defaultv1.0.4
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
-rw-r--r-- | paxinc.c | 12 | ||||
-rw-r--r-- | paxinc.h | 5 | ||||
-rw-r--r-- | scanelf.c | 2 | ||||
-rw-r--r-- | scanmacho.c | 2 |
4 files changed, 13 insertions, 8 deletions
@@ -17,7 +17,7 @@ char do_reverse_endian; #define AR_MAGIC "!<arch>" #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; } @@ -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); @@ -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; |