diff options
author | obrien <obrien@FreeBSD.org> | 2009-05-04 00:37:44 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2009-05-04 00:37:44 +0000 |
commit | a8abfd3eba1e14d222768ebf8316ec02e56af39a (patch) | |
tree | 12756817ab8bc4334652c625c7731c9e7fd0cefc /contrib/file/readelf.c | |
parent | 3222e9c2cde262a2a5a46f45f0a1e06623f69433 (diff) | |
parent | 3d89d1fbe920995209cda59ff0fd5096b6471133 (diff) | |
download | FreeBSD-src-a8abfd3eba1e14d222768ebf8316ec02e56af39a.zip FreeBSD-src-a8abfd3eba1e14d222768ebf8316ec02e56af39a.tar.gz |
Merge vendor/file/dist@191739, bringing FILE 5.00 to 8-CURRENT.
Diffstat (limited to 'contrib/file/readelf.c')
-rw-r--r-- | contrib/file/readelf.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/contrib/file/readelf.c b/contrib/file/readelf.c index 9dcaf09..6f0b328 100644 --- a/contrib/file/readelf.c +++ b/contrib/file/readelf.c @@ -26,6 +26,10 @@ */ #include "file.h" +#ifndef lint +FILE_RCSID("@(#)$File: readelf.c,v 1.81 2008/11/04 16:38:28 christos Exp $") +#endif + #ifdef BUILTIN_ELF #include <string.h> #include <ctype.h> @@ -37,10 +41,6 @@ #include "readelf.h" #include "magic.h" -#ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.76 2008/07/16 18:00:57 christos Exp $") -#endif - #ifdef ELFCORE private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int *); @@ -875,7 +875,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, noff = 0; for (;;) { - if (noff >= (size_t)xsh_size) + if (noff >= (off_t)xsh_size) break; noff = donote(ms, nbuf, (size_t)noff, (size_t)xsh_size, clazz, swap, 4, @@ -907,8 +907,9 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, for (;;) { Elf32_Cap cap32; Elf64_Cap cap64; - char cbuf[MAX(sizeof cap32, sizeof cap64)]; - if ((coff += xcap_sizeof) >= (size_t)xsh_size) + char cbuf[/*CONSTCOND*/ + MAX(sizeof cap32, sizeof cap64)]; + if ((coff += xcap_sizeof) >= (off_t)xsh_size) break; if (read(fd, cbuf, (size_t)xcap_sizeof) != (ssize_t)xcap_sizeof) { @@ -929,7 +930,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, if (file_printf(ms, ", with unknown capability " "0x%llx = 0x%llx", - xcap_tag, xcap_val) == -1) + (unsigned long long)xcap_tag, + (unsigned long long)xcap_val) == -1) return -1; break; } @@ -976,11 +978,12 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, if (cap_hw1) if (file_printf(ms, " unknown hardware capability 0x%llx", - cap_hw1) == -1) + (unsigned long long)cap_hw1) == -1) return -1; } else { if (file_printf(ms, - " hardware capability 0x%llx", cap_hw1) == -1) + " hardware capability 0x%llx", + (unsigned long long)cap_hw1) == -1) return -1; } } @@ -996,7 +999,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, if (cap_sf1) if (file_printf(ms, ", with unknown software capability 0x%llx", - cap_sf1) == -1) + (unsigned long long)cap_sf1) == -1) return -1; } return 0; @@ -1138,7 +1141,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf, Elf64_Ehdr elf64hdr; uint16_t type; - if (ms->flags & MAGIC_MIME) + if (ms->flags & (MAGIC_MIME|MAGIC_APPLE)) return 0; /* * ELF executables have multiple section headers in arbitrary |