aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-07-13 04:59:13 -0400
committerMike Frysinger <vapier@gentoo.org>2015-07-13 04:59:13 -0400
commit9daf7217a29e8542ad80672a3b82ae1b8c497321 (patch)
tree4604bbfc5b14b82d1cb3a0b07d21922cd907c470 /paxinc.c
parentscanelf: include filename/details in all ar related messages (diff)
downloadpax-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
Diffstat (limited to 'paxinc.c')
-rw-r--r--paxinc.c12
1 files changed, 8 insertions, 4 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 "!<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;
}