From 83d9a87348b8d40a605e5b4e2429377678b666b2 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 03 2016 06:22:39 +0000 Subject: import file-5.11-33.el7 --- diff --git a/SOURCES/file-4.17-rpm-name.patch b/SOURCES/file-4.17-rpm-name.patch index bfb9242..3925d55 100644 --- a/SOURCES/file-4.17-rpm-name.patch +++ b/SOURCES/file-4.17-rpm-name.patch @@ -2,7 +2,7 @@ diff --git a/magic/Magdir/rpm b/magic/Magdir/rpm index 4eb5556..fe22b3d 100644 --- a/magic/Magdir/rpm +++ b/magic/Magdir/rpm -@@ -28,6 +28,7 @@ +@@ -29,6 +29,7 @@ >>8 beshort 17 SuperH >>8 beshort 18 Xtensa >>8 beshort 255 noarch diff --git a/SOURCES/file-5.04-minix.patch b/SOURCES/file-5.04-minix.patch index 27f10db..3350068 100644 --- a/SOURCES/file-5.04-minix.patch +++ b/SOURCES/file-5.04-minix.patch @@ -2,7 +2,7 @@ diff --git a/magic/Magdir/filesystems b/magic/Magdir/filesystems index 9172dcb..25c24ca 100644 --- a/magic/Magdir/filesystems +++ b/magic/Magdir/filesystems -@@ -1351,32 +1351,40 @@ +@@ -885,32 +885,40 @@ # Minix filesystems - Juan Cespedes 0x410 leshort 0x137f !:strength / 2 diff --git a/SOURCES/file-5.11-CVE-2014-0207.patch b/SOURCES/file-5.11-CVE-2014-0207.patch index 14f16bc..6b04b62 100644 --- a/SOURCES/file-5.11-CVE-2014-0207.patch +++ b/SOURCES/file-5.11-CVE-2014-0207.patch @@ -14,7 +14,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index 4712e84..16649f1 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -367,10 +367,10 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs, +@@ -352,10 +352,10 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs, size_t ss = CDF_SHORT_SEC_SIZE(h); size_t pos = CDF_SHORT_SEC_POS(h, id); assert(ss == len); diff --git a/SOURCES/file-5.11-CVE-2014-0237.patch b/SOURCES/file-5.11-CVE-2014-0237.patch index f533e2d..912d8f2 100644 --- a/SOURCES/file-5.11-CVE-2014-0237.patch +++ b/SOURCES/file-5.11-CVE-2014-0237.patch @@ -13,7 +13,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index dd7177e..8dacd2f 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -942,7 +942,7 @@ int +@@ -929,7 +929,7 @@ int cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h, cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count) { @@ -22,7 +22,7 @@ index dd7177e..8dacd2f 100644 const cdf_summary_info_header_t *si = CAST(const cdf_summary_info_header_t *, sst->sst_tab); const cdf_section_declaration_t *sd = -@@ -957,21 +957,13 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h, +@@ -944,21 +944,13 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h, ssi->si_os = CDF_TOLE2(si->si_os); ssi->si_class = si->si_class; cdf_swap_class(&ssi->si_class); diff --git a/SOURCES/file-5.11-CVE-2014-0238.patch b/SOURCES/file-5.11-CVE-2014-0238.patch index 07a0622..aeed14d 100644 --- a/SOURCES/file-5.11-CVE-2014-0238.patch +++ b/SOURCES/file-5.11-CVE-2014-0238.patch @@ -12,7 +12,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index 8dacd2f..4712e84 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -823,6 +823,10 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, +@@ -810,6 +810,10 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, i, inp[i].pi_id, inp[i].pi_type, q - p, offs)); if (inp[i].pi_type & CDF_VECTOR) { nelements = CDF_GETUINT32(q, 1); @@ -23,7 +23,7 @@ index 8dacd2f..4712e84 100644 o = 2; } else { nelements = 1; -@@ -897,7 +901,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, +@@ -884,7 +888,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, } DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n", nelements)); diff --git a/SOURCES/file-5.11-CVE-2014-3478.patch b/SOURCES/file-5.11-CVE-2014-3478.patch index dc8b2f1..4d3fbe0 100644 --- a/SOURCES/file-5.11-CVE-2014-3478.patch +++ b/SOURCES/file-5.11-CVE-2014-3478.patch @@ -14,7 +14,7 @@ diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic index 21fea6b..01e4977 100644 --- a/src/softmagic.c +++ b/src/softmagic.c -@@ -881,10 +881,18 @@ mconvert(struct magic_set *ms, struct magic *m, int flip) +@@ -818,10 +818,18 @@ mconvert(struct magic_set *ms, struct magic *m) return 1; } case FILE_PSTRING: { diff --git a/SOURCES/file-5.11-CVE-2014-3479.patch b/SOURCES/file-5.11-CVE-2014-3479.patch index 1570695..58c0cd5 100644 --- a/SOURCES/file-5.11-CVE-2014-3479.patch +++ b/SOURCES/file-5.11-CVE-2014-3479.patch @@ -14,7 +14,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index 16649f1..c9a5d50 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -277,13 +277,15 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h, +@@ -267,13 +267,15 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h, { const char *b = (const char *)sst->sst_tab; const char *e = ((const char *)p) + tail; diff --git a/SOURCES/file-5.11-CVE-2014-3480.patch b/SOURCES/file-5.11-CVE-2014-3480.patch index 042f0a9..1d84c15 100644 --- a/SOURCES/file-5.11-CVE-2014-3480.patch +++ b/SOURCES/file-5.11-CVE-2014-3480.patch @@ -14,7 +14,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index c9a5d50..ee467a6 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -470,7 +470,8 @@ size_t +@@ -457,7 +457,8 @@ size_t cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size) { size_t i, j; @@ -24,7 +24,7 @@ index c9a5d50..ee467a6 100644 DPRINTF(("Chain:")); for (j = i = 0; sid >= 0; i++, j++) { -@@ -480,8 +481,8 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size) +@@ -467,8 +468,8 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size) errno = EFTYPE; return (size_t)-1; } diff --git a/SOURCES/file-5.11-CVE-2014-3487.patch b/SOURCES/file-5.11-CVE-2014-3487.patch index 2eddc2e..fe9ed7b 100644 --- a/SOURCES/file-5.11-CVE-2014-3487.patch +++ b/SOURCES/file-5.11-CVE-2014-3487.patch @@ -16,7 +16,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index ee467a6..429f3b9 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -812,7 +812,11 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, +@@ -799,7 +799,11 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) goto out; for (i = 0; i < sh.sh_properties; i++) { diff --git a/SOURCES/file-5.11-CVE-2014-3587.patch b/SOURCES/file-5.11-CVE-2014-3587.patch index 5dcc3a7..ff84da2 100644 --- a/SOURCES/file-5.11-CVE-2014-3587.patch +++ b/SOURCES/file-5.11-CVE-2014-3587.patch @@ -12,7 +12,7 @@ diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index 429f3b9..2c0a2d9 100644 --- a/src/cdf.c +++ b/src/cdf.c -@@ -820,7 +820,7 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, +@@ -807,7 +807,7 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, q = (const uint8_t *)(const void *) ((const char *)(const void *)p + ofs - 2 * sizeof(uint32_t)); diff --git a/SOURCES/file-5.11-CVE-2014-3710.patch b/SOURCES/file-5.11-CVE-2014-3710.patch index 71303a3..1bc5dcf 100644 --- a/SOURCES/file-5.11-CVE-2014-3710.patch +++ b/SOURCES/file-5.11-CVE-2014-3710.patch @@ -16,7 +16,7 @@ diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c index 1c3845f..bb6f70f 100644 --- a/src/readelf.c +++ b/src/readelf.c -@@ -372,6 +372,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, +@@ -366,6 +366,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, uint32_t namesz, descsz; unsigned char *nbuf = CAST(unsigned char *, vbuf); diff --git a/SOURCES/file-5.11-CVE-2014-9652.patch b/SOURCES/file-5.11-CVE-2014-9652.patch index 2384d90..85df25d 100644 --- a/SOURCES/file-5.11-CVE-2014-9652.patch +++ b/SOURCES/file-5.11-CVE-2014-9652.patch @@ -12,7 +12,7 @@ diff --git a/src/softmagic.c b/src/softmagic.c index dbb670a..2b15f2c 100644 --- a/src/softmagic.c +++ b/src/softmagic.c -@@ -964,14 +964,17 @@ mconvert(struct magic_set *ms, struct magic *m, int flip) +@@ -822,14 +822,17 @@ mconvert(struct magic_set *ms, struct magic *m) size_t sz = file_pstring_length_size(m); char *ptr1 = p->s, *ptr2 = ptr1 + sz; size_t len = file_pstring_get_length(m, ptr1); diff --git a/SOURCES/file-5.11-auxv.patch b/SOURCES/file-5.11-auxv.patch new file mode 100644 index 0000000..9fddea9 --- /dev/null +++ b/SOURCES/file-5.11-auxv.patch @@ -0,0 +1,564 @@ +diff --git a/src/readelf.c b/src/readelf.c +index 9651239..807affc 100644 +--- a/src/readelf.c ++++ b/src/readelf.c +@@ -41,6 +41,8 @@ FILE_RCSID("@(#)$File: readelf.c,v 1.90 2011/08/23 08:01:12 christos Exp $") + #include "readelf.h" + #include "magic.h" + ++#define __arraycount(a) (sizeof(a) / sizeof(a[0])) ++ + #ifdef ELFCORE + private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t, + off_t, int *); +@@ -50,7 +52,7 @@ private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, + private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, + off_t, int *, int, int); + private size_t donote(struct magic_set *, void *, size_t, size_t, int, +- int, size_t, int *); ++ int, size_t, int *, int, off_t, int, off_t); + + #define ELF_ALIGN(a) ((((a) + align - 1) / align) * align) + +@@ -184,6 +186,11 @@ getu64(int swap, uint64_t value) + elf_getu32(swap, ph32.p_align) : 4) \ + : (off_t) (ph64.p_align ? \ + elf_getu64(swap, ph64.p_align) : 4))) ++#define xph_vaddr (size_t)((clazz == ELFCLASS32 \ ++ ? (off_t) (ph32.p_vaddr ? \ ++ elf_getu32(swap, ph32.p_vaddr) : 4) \ ++ : (off_t) (ph64.p_vaddr ? \ ++ elf_getu64(swap, ph64.p_vaddr) : 4))) + #define xph_filesz (size_t)((clazz == ELFCLASS32 \ + ? elf_getu32(swap, ph32.p_filesz) \ + : elf_getu64(swap, ph64.p_filesz))) +@@ -194,8 +201,8 @@ getu64(int swap, uint64_t value) + ? elf_getu32(swap, ph32.p_memsz) \ + : elf_getu64(swap, ph64.p_memsz))) + #define xnh_sizeof (clazz == ELFCLASS32 \ +- ? sizeof nh32 \ +- : sizeof nh64) ++ ? sizeof(nh32) \ ++ : sizeof(nh64)) + #define xnh_type (clazz == ELFCLASS32 \ + ? elf_getu32(swap, nh32.n_type) \ + : elf_getu32(swap, nh64.n_type)) +@@ -220,6 +227,18 @@ getu64(int swap, uint64_t value) + #define xcap_val (clazz == ELFCLASS32 \ + ? elf_getu32(swap, cap32.c_un.c_val) \ + : elf_getu64(swap, cap64.c_un.c_val)) ++#define xauxv_addr (clazz == ELFCLASS32 \ ++ ? (void *)&auxv32 \ ++ : (void *)&auxv64) ++#define xauxv_sizeof (clazz == ELFCLASS32 \ ++ ? sizeof(auxv32) \ ++ : sizeof(auxv64)) ++#define xauxv_type (clazz == ELFCLASS32 \ ++ ? elf_getu32(swap, auxv32.a_type) \ ++ : elf_getu64(swap, auxv64.a_type)) ++#define xauxv_val (clazz == ELFCLASS32 \ ++ ? elf_getu32(swap, auxv32.a_v) \ ++ : elf_getu64(swap, auxv64.a_v)) + + #ifdef ELFCORE + /* +@@ -306,6 +325,7 @@ private const char os_style_names[][8] = { + #define FLAGS_DID_BUILD_ID 0x04 + #define FLAGS_DID_CORE_STYLE 0x08 + #define FLAGS_IS_CORE 0x10 ++#define FLAGS_DID_AUXV 0x200 + + private int + dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, +@@ -316,6 +336,8 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + size_t offset, len; + unsigned char nbuf[BUFSIZ]; + ssize_t bufsize; ++ off_t ph_off = off; ++ int ph_num = num; + + if (size != xph_sizeof) { + if (file_printf(ms, ", corrupted program header size") == -1) +@@ -355,7 +377,8 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + if (offset >= (size_t)bufsize) + break; + offset = donote(ms, nbuf, offset, (size_t)bufsize, +- clazz, swap, 4, flags); ++ clazz, swap, 4, flags, fd, ph_off, ++ ph_num, fsize); + if (offset == 0) + break; + +@@ -365,9 +388,160 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + } + #endif + ++private off_t ++get_offset_from_virtaddr(struct magic_set *ms, int swap, int clazz, int fd, ++ off_t off, int num, off_t fsize, uint64_t virtaddr) ++{ ++ Elf32_Phdr ph32; ++ Elf64_Phdr ph64; ++ ++ /* ++ * Loop through all the program headers and find the header with ++ * virtual address in which the "virtaddr" belongs to. ++ */ ++ for ( ; num; num--) { ++ if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) { ++ file_badread(ms); ++ return -1; ++ } ++ off += xph_sizeof; ++ ++ if (xph_offset > fsize) { ++ /* Perhaps warn here */ ++ continue; ++ } ++ ++ if (virtaddr >= xph_vaddr && virtaddr < xph_vaddr + xph_filesz) ++ return xph_offset + (virtaddr - xph_vaddr); ++ } ++ return 0; ++} ++ ++private size_t ++get_string_on_virtaddr(struct magic_set *ms, ++ int swap, int clazz, int fd, off_t ph_off, int ph_num, ++ off_t fsize, uint64_t virtaddr, char *buf, ssize_t buflen) ++{ ++ char *bptr; ++ off_t offset; ++ ++ if (buflen == 0) ++ return 0; ++ ++ offset = get_offset_from_virtaddr(ms, swap, clazz, fd, ph_off, ph_num, ++ fsize, virtaddr); ++ if (offset < 0 || (buflen = pread(fd, buf, buflen, offset)) <= 0) { ++ file_badread(ms); ++ return 0; ++ } ++ ++ buf[buflen - 1] = '\0'; ++ ++ /* We expect only printable characters, so return if buffer contains ++ * non-printable character before the '\0' or just '\0'. */ ++ for (bptr = buf; *bptr && isprint((unsigned char)*bptr); bptr++) ++ continue; ++ if (*bptr != '\0') ++ return 0; ++ ++ return bptr - buf; ++} ++ ++ ++private int ++do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, ++ int swap, uint32_t namesz __attribute__((__unused__)), ++ uint32_t descsz __attribute__((__unused__)), ++ size_t noff __attribute__((__unused__)), size_t doff, ++ int *flags, size_t size __attribute__((__unused__)), int clazz, ++ int fd, off_t ph_off, int ph_num, off_t fsize) ++{ ++#ifdef ELFCORE ++ Aux32Info auxv32; ++ Aux64Info auxv64; ++ size_t elsize = xauxv_sizeof; ++ const char *tag; ++ int is_string; ++ size_t nval; ++ size_t off; ++ ++ ++ if (type != NT_AUXV || (*flags & FLAGS_IS_CORE) == 0) ++ return 0; ++ ++ *flags |= FLAGS_DID_AUXV; ++ ++ nval = 0; ++ for (off = 0; off + elsize <= descsz; off += elsize) { ++ (void)memcpy(xauxv_addr, &nbuf[doff + off], xauxv_sizeof); ++ /* Limit processing to 50 vector entries to prevent DoS */ ++ if (nval++ >= 50) { ++ file_error(ms, 0, "Too many ELF Auxv elements"); ++ return 1; ++ } ++ ++ switch(xauxv_type) { ++ case AT_LINUX_EXECFN: ++ is_string = 1; ++ tag = "execfn"; ++ break; ++ case AT_LINUX_PLATFORM: ++ is_string = 1; ++ tag = "platform"; ++ break; ++ case AT_LINUX_UID: ++ is_string = 0; ++ tag = "real uid"; ++ break; ++ case AT_LINUX_GID: ++ is_string = 0; ++ tag = "real gid"; ++ break; ++ case AT_LINUX_EUID: ++ is_string = 0; ++ tag = "effective uid"; ++ break; ++ case AT_LINUX_EGID: ++ is_string = 0; ++ tag = "effective gid"; ++ break; ++ default: ++ is_string = 0; ++ tag = NULL; ++ break; ++ } ++ ++ if (tag == NULL) ++ continue; ++ ++ if (is_string) { ++ char buf[256]; ++ ssize_t buflen; ++ buflen = get_string_on_virtaddr(ms, swap, clazz, fd, ++ ph_off, ph_num, fsize, xauxv_val, buf, sizeof(buf)); ++ ++ if (buflen == 0) ++ continue; ++ ++ if (file_printf(ms, ", %s: '%s'", tag, buf) == -1) ++ return 0; ++ } else { ++ if (file_printf(ms, ", %s: %d", tag, (int) xauxv_val) ++ == -1) ++ return 0; ++ } ++ } ++ return 1; ++#else ++ return 0; ++#endif ++} ++ ++ + private size_t + donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, +- int clazz, int swap, size_t align, int *flags) ++ int clazz, int swap, size_t align, int *flags, ++ int fd, off_t ph_off, int ph_num, off_t fsize) + { + Elf32_Nhdr nh32; + Elf64_Nhdr nh64; +@@ -390,6 +564,7 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + + namesz = xnh_namesz; + descsz = xnh_descsz; ++ + if ((namesz == 0) && (descsz == 0)) { + /* + * We're out of note headers. +@@ -438,37 +613,37 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + (void)memcpy(desc, &nbuf[doff], sizeof(desc)); + + if (file_printf(ms, ", for GNU/") == -1) +- return size; ++ return offset; + switch (elf_getu32(swap, desc[0])) { + case GNU_OS_LINUX: + if (file_printf(ms, "Linux") == -1) +- return size; ++ return offset; + break; + case GNU_OS_HURD: + if (file_printf(ms, "Hurd") == -1) +- return size; ++ return offset; + break; + case GNU_OS_SOLARIS: + if (file_printf(ms, "Solaris") == -1) +- return size; ++ return offset; + break; + case GNU_OS_KFREEBSD: + if (file_printf(ms, "kFreeBSD") == -1) +- return size; ++ return offset; + break; + case GNU_OS_KNETBSD: + if (file_printf(ms, "kNetBSD") == -1) +- return size; ++ return offset; + break; + default: + if (file_printf(ms, "") == -1) +- return size; ++ return offset; + } + if (file_printf(ms, " %d.%d.%d", elf_getu32(swap, desc[1]), + elf_getu32(swap, desc[2]), elf_getu32(swap, desc[3])) == -1) +- return size; ++ return offset; + *flags |= FLAGS_DID_NOTE; +- return size; ++ return offset; + } + + if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 && +@@ -492,7 +667,7 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + desc = elf_getu32(swap, desc); + + if (file_printf(ms, ", for NetBSD") == -1) +- return size; ++ return offset; + /* + * The version number used to be stuck as 199905, and was thus + * basically content-free. Newer versions of NetBSD have fixed +@@ -512,23 +687,23 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + uint32_t ver_maj = desc / 100000000; + + if (file_printf(ms, " %u.%u", ver_maj, ver_min) == -1) +- return size; ++ return offset; + if (ver_rel == 0 && ver_patch != 0) { + if (file_printf(ms, ".%u", ver_patch) == -1) +- return size; ++ return offset; + } else if (ver_rel != 0) { + while (ver_rel > 26) { + if (file_printf(ms, "Z") == -1) +- return size; ++ return offset; + ver_rel -= 26; + } + if (file_printf(ms, "%c", 'A' + ver_rel - 1) + == -1) +- return size; ++ return offset; + } + } + *flags |= FLAGS_DID_NOTE; +- return size; ++ return offset; + } + + if (namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0 && +@@ -537,7 +712,7 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + (void)memcpy(&desc, &nbuf[doff], sizeof(desc)); + desc = elf_getu32(swap, desc); + if (file_printf(ms, ", for FreeBSD") == -1) +- return size; ++ return offset; + + /* + * Contents is __FreeBSD_version, whose relation to OS +@@ -567,69 +742,69 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + */ + if (desc == 460002) { + if (file_printf(ms, " 4.6.2") == -1) +- return size; ++ return offset; + } else if (desc < 460100) { + if (file_printf(ms, " %d.%d", desc / 100000, + desc / 10000 % 10) == -1) +- return size; ++ return offset; + if (desc / 1000 % 10 > 0) + if (file_printf(ms, ".%d", desc / 1000 % 10) + == -1) +- return size; ++ return offset; + if ((desc % 1000 > 0) || (desc % 100000 == 0)) + if (file_printf(ms, " (%d)", desc) == -1) +- return size; ++ return offset; + } else if (desc < 500000) { + if (file_printf(ms, " %d.%d", desc / 100000, + desc / 10000 % 10 + desc / 1000 % 10) == -1) +- return size; ++ return offset; + if (desc / 100 % 10 > 0) { + if (file_printf(ms, " (%d)", desc) == -1) +- return size; ++ return offset; + } else if (desc / 10 % 10 > 0) { + if (file_printf(ms, ".%d", desc / 10 % 10) + == -1) +- return size; ++ return offset; + } + } else { + if (file_printf(ms, " %d.%d", desc / 100000, + desc / 1000 % 100) == -1) +- return size; ++ return offset; + if ((desc / 100 % 10 > 0) || + (desc % 100000 / 100 == 0)) { + if (file_printf(ms, " (%d)", desc) == -1) +- return size; ++ return offset; + } else if (desc / 10 % 10 > 0) { + if (file_printf(ms, ".%d", desc / 10 % 10) + == -1) +- return size; ++ return offset; + } + } + *flags |= FLAGS_DID_NOTE; +- return size; ++ return offset; + } + + if (namesz == 8 && strcmp((char *)&nbuf[noff], "OpenBSD") == 0 && + xnh_type == NT_OPENBSD_VERSION && descsz == 4) { + if (file_printf(ms, ", for OpenBSD") == -1) +- return size; ++ return offset; + /* Content of note is always 0 */ + *flags |= FLAGS_DID_NOTE; +- return size; ++ return offset; + } + + if (namesz == 10 && strcmp((char *)&nbuf[noff], "DragonFly") == 0 && + xnh_type == NT_DRAGONFLY_VERSION && descsz == 4) { + uint32_t desc; + if (file_printf(ms, ", for DragonFly") == -1) +- return size; ++ return offset; + (void)memcpy(&desc, &nbuf[doff], sizeof(desc)); + desc = elf_getu32(swap, desc); + if (file_printf(ms, " %d.%d.%d", desc / 100000, + desc / 10000 % 10, desc % 10000) == -1) +- return size; ++ return offset; + *flags |= FLAGS_DID_NOTE; +- return size; ++ return offset; + } + + core: +@@ -661,14 +836,22 @@ core: + os_style = OS_STYLE_NETBSD; + } + ++ if ((*flags & FLAGS_DID_AUXV) == 0) { ++ if (do_auxv_note(ms, nbuf, xnh_type, swap, ++ namesz, descsz, noff, doff, flags, size, clazz, ++ fd, ph_off, ph_num, fsize)) ++ return offset; ++ } ++ ++ + #ifdef ELFCORE + if ((*flags & FLAGS_DID_CORE) != 0) +- return size; ++ return offset; + + if (os_style != -1 && (*flags & FLAGS_DID_CORE_STYLE) == 0) { + if (file_printf(ms, ", %s-style", os_style_names[os_style]) + == -1) +- return size; ++ return offset; + *flags |= FLAGS_DID_CORE_STYLE; + } + +@@ -683,7 +866,7 @@ core: + */ + if (file_printf(ms, ", from '%.31s'", + &nbuf[doff + 0x7c]) == -1) +- return size; ++ return offset; + + /* + * Extract the signal number. It is at +@@ -693,9 +876,9 @@ core: + sizeof(signo)); + if (file_printf(ms, " (signal %u)", + elf_getu32(swap, signo)) == -1) +- return size; ++ return offset; + *flags |= FLAGS_DID_CORE; +- return size; ++ return offset; + } + break; + +@@ -793,9 +976,9 @@ core: + cp--; + if (file_printf(ms, ", from '%.*s'", + (int)(cp - cname), cname) == -1) +- return size; ++ return offset; + *flags |= FLAGS_DID_CORE; +- return size; ++ return offset; + + tryanother: + ; +@@ -936,7 +1119,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, + if (noff >= (off_t)xsh_size) + break; + noff = donote(ms, nbuf, (size_t)noff, +- xsh_size, clazz, swap, 4, flags); ++ xsh_size, clazz, swap, 4, flags, 0, 0, 0, 0); + if (noff == 0) + break; + } +@@ -1130,7 +1313,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + break; + offset = donote(ms, nbuf, offset, + (size_t)bufsize, clazz, swap, align, +- flags); ++ flags, 0, 0, 0, 0); + if (offset == 0) + break; + } +diff --git a/src/readelf.h b/src/readelf.h +index ab4b5d1..fb34585 100644 +--- a/src/readelf.h ++++ b/src/readelf.h +@@ -62,6 +62,42 @@ typedef uint8_t Elf64_Char; + #define EI_NIDENT 16 + + typedef struct { ++ Elf32_Word a_type; /* 32-bit id */ ++ Elf32_Word a_v; /* 32-bit id */ ++} Aux32Info; ++ ++typedef struct { ++ Elf64_Xword a_type; /* 64-bit id */ ++ Elf64_Xword a_v; /* 64-bit id */ ++} Aux64Info; ++ ++#define AT_NULL 0 /* end of vector */ ++#define AT_IGNORE 1 /* entry should be ignored */ ++#define AT_EXECFD 2 /* file descriptor of program */ ++#define AT_PHDR 3 /* program headers for program */ ++#define AT_PHENT 4 /* size of program header entry */ ++#define AT_PHNUM 5 /* number of program headers */ ++#define AT_PAGESZ 6 /* system page size */ ++#define AT_BASE 7 /* base address of interpreter */ ++#define AT_FLAGS 8 /* flags */ ++#define AT_ENTRY 9 /* entry point of program */ ++#define AT_LINUX_NOTELF 10 /* program is not ELF */ ++#define AT_LINUX_UID 11 /* real uid */ ++#define AT_LINUX_EUID 12 /* effective uid */ ++#define AT_LINUX_GID 13 /* real gid */ ++#define AT_LINUX_EGID 14 /* effective gid */ ++#define AT_LINUX_PLATFORM 15 /* string identifying CPU for optimizations */ ++#define AT_LINUX_HWCAP 16 /* arch dependent hints at CPU capabilities */ ++#define AT_LINUX_CLKTCK 17 /* frequency at which times() increments */ ++/* AT_* values 18 through 22 are reserved */ ++#define AT_LINUX_SECURE 23 /* secure mode boolean */ ++#define AT_LINUX_BASE_PLATFORM 24 /* string identifying real platform, may ++ * differ from AT_PLATFORM. */ ++#define AT_LINUX_RANDOM 25 /* address of 16 random bytes */ ++#define AT_LINUX_HWCAP2 26 /* extension of AT_HWCAP */ ++#define AT_LINUX_EXECFN 31 /* filename of program */ ++ ++typedef struct { + Elf32_Char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; diff --git a/SOURCES/file-5.11-buildid.patch b/SOURCES/file-5.11-buildid.patch index f06487c..d27e127 100644 --- a/SOURCES/file-5.11-buildid.patch +++ b/SOURCES/file-5.11-buildid.patch @@ -11,7 +11,7 @@ diff --git a/src/readelf.c b/src/readelf.c index deb6d31..158f789 100644 --- a/src/readelf.c +++ b/src/readelf.c -@@ -465,13 +465,14 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, +@@ -473,13 +473,14 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 && xnh_type == NT_GNU_BUILD_ID && (descsz == 16 || descsz == 20)) { diff --git a/SOURCES/file-5.11-java1718.patch b/SOURCES/file-5.11-java1718.patch new file mode 100644 index 0000000..5a8ed81 --- /dev/null +++ b/SOURCES/file-5.11-java1718.patch @@ -0,0 +1,13 @@ +diff --git a/magic/Magdir/cafebabe b/magic/Magdir/cafebabe +index 6400e2f..6f2e96d 100644 +--- a/magic/Magdir/cafebabe ++++ b/magic/Magdir/cafebabe +@@ -27,6 +27,8 @@ + >>4 belong 0x0030 (Java 1.4) + >>4 belong 0x0031 (Java 1.5) + >>4 belong 0x0032 (Java 1.6) ++>>4 belong 0x0033 (Java 1.7) ++>>4 belong 0x0034 (Java 1.8) + + + 0 belong 0xcafebabe diff --git a/SOURCES/file-5.11-newpython.patch b/SOURCES/file-5.11-newpython.patch new file mode 100644 index 0000000..ad80258 --- /dev/null +++ b/SOURCES/file-5.11-newpython.patch @@ -0,0 +1,14 @@ +diff --git a/magic/Magdir/python b/magic/Magdir/python +index 23f8d6b..6d7121a 100644 +--- a/magic/Magdir/python ++++ b/magic/Magdir/python +@@ -22,6 +22,9 @@ + 0 belong 0x3b0c0d0a python 3.0 byte-compiled + 0 belong 0x4f0c0d0a python 3.1 byte-compiled + 0 belong 0x6c0c0d0a python 3.2 byte-compiled ++0 belong 0x9e0c0d0a python 3.3 byte-compiled ++0 belong 0xee0c0d0a python 3.4 byte-compiled ++0 belong 0x160d0d0a python 3.5 byte-compiled + + 0 search/1/w #!\ /usr/bin/python Python script text executable + !:mime text/x-python diff --git a/SOURCES/file-5.11-offset-oob.patch b/SOURCES/file-5.11-offset-oob.patch index a143f44..e72ebda 100644 --- a/SOURCES/file-5.11-offset-oob.patch +++ b/SOURCES/file-5.11-offset-oob.patch @@ -11,7 +11,7 @@ index 8d08cad..6dc86f5 100644 private int match(struct magic_set *, struct magic *, uint32_t, const unsigned char *, size_t, int, int, int); private int mget(struct magic_set *, const unsigned char *, -@@ -1582,7 +1580,7 @@ mget(struct magic_set *ms, const unsigned char *s, +@@ -1601,7 +1599,7 @@ mget(struct magic_set *ms, const unsigned char *s, break; case FILE_REGEX: @@ -20,7 +20,7 @@ index 8d08cad..6dc86f5 100644 return 0; break; -@@ -1592,7 +1590,7 @@ mget(struct magic_set *ms, const unsigned char *s, +@@ -1611,7 +1609,7 @@ mget(struct magic_set *ms, const unsigned char *s, return -1; if (offset == 0) return 0; diff --git a/SOURCES/file-5.11-pascal.patch b/SOURCES/file-5.11-pascal.patch new file mode 100644 index 0000000..5a39a4b --- /dev/null +++ b/SOURCES/file-5.11-pascal.patch @@ -0,0 +1,16 @@ +diff --git a/magic/Magdir/pascal b/magic/Magdir/pascal +index a134a47..d8e61c6 100644 +--- a/magic/Magdir/pascal ++++ b/magic/Magdir/pascal +@@ -4,7 +4,7 @@ + # + 0 search/8192 (input, Pascal source text + !:mime text/x-pascal +-0 regex \^program Pascal source text +-!:mime text/x-pascal +-0 regex \^record Pascal source text +-!:mime text/x-pascal ++#0 regex \^program Pascal source text ++#!:mime text/x-pascal ++#0 regex \^record Pascal source text ++#!:mime text/x-pascal diff --git a/SOURCES/file-5.11-qcow3.patch b/SOURCES/file-5.11-qcow3.patch index b7a4806..70f43fa 100644 --- a/SOURCES/file-5.11-qcow3.patch +++ b/SOURCES/file-5.11-qcow3.patch @@ -2,7 +2,7 @@ diff --git a/magic/Magdir/msdos b/magic/Magdir/msdos index 8f3e532..21f055d 100644 --- a/magic/Magdir/msdos +++ b/magic/Magdir/msdos -@@ -820,6 +820,21 @@ +@@ -811,6 +811,21 @@ >>24 bequad x \b, %lld bytes >>32 belong 1 \b, AES-encrypted diff --git a/SOURCES/file-5.11-version.patch b/SOURCES/file-5.11-version.patch new file mode 100644 index 0000000..de75812 --- /dev/null +++ b/SOURCES/file-5.11-version.patch @@ -0,0 +1,27 @@ +From 5c9813d05317379b38e04b1b7ffb8cca6a236143 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Thu, 6 Sep 2012 14:18:50 +0000 +Subject: [PATCH] PR/198: Version should not exit 1 + +Upstream-commit: a5a197f98d6ad293a25f3e20563aab31906c5ab3 +Signed-off-by: Kamil Dudka +--- + src/file.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/file.c b/src/file.c +index 408ec63..7911b07 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -252,7 +252,7 @@ main(int argc, char *argv[]) + (void)fprintf(stdout, "%s-%s\n", progname, VERSION); + (void)fprintf(stdout, "magic file from %s\n", + magicfile); +- return 1; ++ return 0; + case 'z': + flags |= MAGIC_COMPRESS; + break; +-- +2.5.5 + diff --git a/SPECS/file.spec b/SPECS/file.spec index f2ed32c..459222a 100644 --- a/SPECS/file.spec +++ b/SPECS/file.spec @@ -5,7 +5,7 @@ Summary: A utility for determining file types Name: file Version: 5.11 -Release: 31%{?dist} +Release: 33%{?dist} License: BSD Group: Applications/File Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz @@ -58,6 +58,14 @@ Patch51: file-5.11-CVE-2014-9652.patch Patch52: file-5.11-CVE-2014-9653.patch Patch53: file-5.11-xml.patch Patch54: file-5.11-buildid.patch +Patch55: file-5.11-java1718.patch +Patch56: file-5.11-auxv.patch +Patch57: file-5.11-newpython.patch +Patch58: file-5.11-pascal.patch + +# fix #1246385 - 'file --version' now exits successfully +Patch59: file-5.11-version.patch + URL: http://www.darwinsys.com/file/ Requires: file-libs = %{version}-%{release} BuildRequires: zlib-devel @@ -158,6 +166,11 @@ file(1) command. %patch52 -p1 %patch53 -p1 %patch54 -p1 +%patch55 -p1 +%patch56 -p1 +%patch57 -p1 +%patch58 -p1 +%patch59 -p1 # Patches can generate *.orig files, which can't stay in the magic dir, # otherwise there will be problems when compiling magic file! @@ -237,6 +250,15 @@ cd python %endif %changelog +* Mon Jun 27 2016 Kamil Dudka 5.11-33 +- fix #1246385 - 'file --version' now exits successfully + +* Wed Mar 09 2016 Jan Kaluza 5.11-32 +- fix #1278737 - add support for Java 1.7 and 1.8 +- fix #1281723 - show full executable name for core +- fix #1271636 - add support for detection of Python 2.7 byte-compiled files +- fix #1278768 - comment out too-sensitive Pascal magic + * Mon Sep 07 2015 Jan Kaluza - 5.11-31 - fix #1255396 - Make the build ID output consistent with other tools