svn commit: r299716 - in vendor/file/dist: . magic/Magdir src tests
Slawa Olhovchenkov
slw at zxy.spb.ru
Sat May 14 10:08:07 UTC 2016
On Sat, May 14, 2016 at 05:25:47AM +0000, Xin LI wrote:
> Author: delphij
> Date: Sat May 14 05:25:47 2016
> New Revision: 299716
> URL: https://svnweb.freebsd.org/changeset/base/299716
>
> Log:
> Vendor import of file 4.27.
4.27?
> Modified:
> vendor/file/dist/ChangeLog
> vendor/file/dist/configure
> vendor/file/dist/configure.ac
> vendor/file/dist/magic/Magdir/archive
> vendor/file/dist/magic/Magdir/commands
> vendor/file/dist/magic/Magdir/console
> vendor/file/dist/magic/Magdir/os2
> vendor/file/dist/magic/Magdir/xenix
> vendor/file/dist/src/ascmagic.c
> vendor/file/dist/src/cdf.c
> vendor/file/dist/src/cdf.h
> vendor/file/dist/src/compress.c
> vendor/file/dist/src/der.c
> vendor/file/dist/src/magic.c
> vendor/file/dist/src/magic.h
> vendor/file/dist/src/magic.h.in
> vendor/file/dist/src/readcdf.c
> vendor/file/dist/src/softmagic.c
> vendor/file/dist/tests/Makefile.am
> vendor/file/dist/tests/Makefile.in
>
> Modified: vendor/file/dist/ChangeLog
> ==============================================================================
> --- vendor/file/dist/ChangeLog Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/ChangeLog Sat May 14 05:25:47 2016 (r299716)
> @@ -1,6 +1,19 @@
> +2016-05-13 12:00 Christos Zoulas <christos at zoulas.com>
> +
> + * release 5.27
> +
> +2016-04-18 9:35 Christos Zoulas <christos at zoulas.com>
> +
> + * Errors comparing DER entries or computing offsets
> + are just indications of malformed non-DER files.
> + Don't print them.
> + * Offset comparison was off-by-one.
> + * Fix compression code (Werner Fink)
> + * Put new bytes constant in the right file (not the generated one)
> +
> 2016-04-16 18:34 Christos Zoulas <christos at zoulas.com>
>
> - * release 5.25
> + * release 5.26
>
> 2016-03-31 13:50 Christos Zoulas <christos at zoulas.com>
>
>
> Modified: vendor/file/dist/configure
> ==============================================================================
> --- vendor/file/dist/configure Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/configure Sat May 14 05:25:47 2016 (r299716)
> @@ -1,6 +1,6 @@
> #! /bin/sh
> # Guess values for system-dependent variables and create Makefiles.
> -# Generated by GNU Autoconf 2.69 for file 5.26.
> +# Generated by GNU Autoconf 2.69 for file 5.27.
> #
> # Report bugs to <christos at astron.com>.
> #
> @@ -590,8 +590,8 @@ MAKEFLAGS=
> # Identity of this package.
> PACKAGE_NAME='file'
> PACKAGE_TARNAME='file'
> -PACKAGE_VERSION='5.26'
> -PACKAGE_STRING='file 5.26'
> +PACKAGE_VERSION='5.27'
> +PACKAGE_STRING='file 5.27'
> PACKAGE_BUGREPORT='christos at astron.com'
> PACKAGE_URL=''
>
> @@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
> # Omit some internal or obsolete options to make the list less imposing.
> # This message is too long to be a string in the A/UX 3.1 sh.
> cat <<_ACEOF
> -\`configure' configures file 5.26 to adapt to many kinds of systems.
> +\`configure' configures file 5.27 to adapt to many kinds of systems.
>
> Usage: $0 [OPTION]... [VAR=VALUE]...
>
> @@ -1397,7 +1397,7 @@ fi
>
> if test -n "$ac_init_help"; then
> case $ac_init_help in
> - short | recursive ) echo "Configuration of file 5.26:";;
> + short | recursive ) echo "Configuration of file 5.27:";;
> esac
> cat <<\_ACEOF
>
> @@ -1507,7 +1507,7 @@ fi
> test -n "$ac_init_help" && exit $ac_status
> if $ac_init_version; then
> cat <<\_ACEOF
> -file configure 5.26
> +file configure 5.27
> generated by GNU Autoconf 2.69
>
> Copyright (C) 2012 Free Software Foundation, Inc.
> @@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
> This file contains any messages produced by compilers while
> running configure, to aid debugging if configure makes a mistake.
>
> -It was created by file $as_me 5.26, which was
> +It was created by file $as_me 5.27, which was
> generated by GNU Autoconf 2.69. Invocation command line was
>
> $ $0 $@
> @@ -3029,7 +3029,7 @@ fi
>
> # Define the identity of the package.
> PACKAGE='file'
> - VERSION='5.26'
> + VERSION='5.27'
>
>
> cat >>confdefs.h <<_ACEOF
> @@ -15049,7 +15049,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
> # report actual input values of CONFIG_FILES etc. instead of their
> # values after options handling.
> ac_log="
> -This file was extended by file $as_me 5.26, which was
> +This file was extended by file $as_me 5.27, which was
> generated by GNU Autoconf 2.69. Invocation command line was
>
> CONFIG_FILES = $CONFIG_FILES
> @@ -15115,7 +15115,7 @@ _ACEOF
> cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
> ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
> ac_cs_version="\\
> -file config.status 5.26
> +file config.status 5.27
> configured by $0, generated by GNU Autoconf 2.69,
> with options \\"\$ac_cs_config\\"
>
>
> Modified: vendor/file/dist/configure.ac
> ==============================================================================
> --- vendor/file/dist/configure.ac Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/configure.ac Sat May 14 05:25:47 2016 (r299716)
> @@ -1,5 +1,5 @@
> dnl Process this file with autoconf to produce a configure script.
> -AC_INIT([file],[5.26],[christos at astron.com])
> +AC_INIT([file],[5.27],[christos at astron.com])
> AM_INIT_AUTOMAKE([subdir-objects foreign])
> m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
>
>
> Modified: vendor/file/dist/magic/Magdir/archive
> ==============================================================================
> --- vendor/file/dist/magic/Magdir/archive Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/magic/Magdir/archive Sat May 14 05:25:47 2016 (r299716)
> @@ -1,5 +1,5 @@
> #------------------------------------------------------------------------------
> -# $File: archive,v 1.102 2016/01/11 20:59:24 christos Exp $
> +# $File: archive,v 1.103 2016/05/05 17:07:40 christos Exp $
> # archive: file(1) magic for archive formats (see also "msdos" for self-
> # extracting compressed archives)
> #
> @@ -891,6 +891,14 @@
> >(26.s+30) leshort 0xcafe Java archive data (JAR)
> !:mime application/java-archive
>
> +# iOS App
> +>(26.s+30) leshort !0xcafe
> +>>26 string !\x8\0\0\0mimetype
> +>>>30 string Payload/
> +>>>>38 search/64 .app/ iOS App
> +!:mime application/x-ios-app
> +
> +
> # Generic zip archives (Greg Roelofs, c/o zip-bugs at wkuvx1.wku.edu)
> # Next line excludes specialized formats:
> >(26.s+30) leshort !0xcafe
>
> Modified: vendor/file/dist/magic/Magdir/commands
> ==============================================================================
> --- vendor/file/dist/magic/Magdir/commands Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/magic/Magdir/commands Sat May 14 05:25:47 2016 (r299716)
> @@ -1,6 +1,6 @@
>
> #------------------------------------------------------------------------------
> -# $File: commands,v 1.53 2016/02/23 12:35:20 christos Exp $
> +# $File: commands,v 1.54 2016/04/19 13:40:02 christos Exp $
> # commands: file(1) magic for various shells and interpreters
> #
> #0 string/w : shell archive or script for antique kernel text
> @@ -101,7 +101,7 @@
> 0 string =<?php
> >5 regex [\ \n]
> >>6 string /*\ Smarty\ version Smarty compiled template
> ->24 regex [0-9.]+ \b, version %s
> +>>>24 regex [0-9.]+ \b, version %s
> !:mime text/x-php
>
> 0 string Zend\x00 PHP script Zend Optimizer data
>
> Modified: vendor/file/dist/magic/Magdir/console
> ==============================================================================
> --- vendor/file/dist/magic/Magdir/console Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/magic/Magdir/console Sat May 14 05:25:47 2016 (r299716)
> @@ -1,6 +1,6 @@
>
> #------------------------------------------------------------------------------
> -# $File: console,v 1.24 2016/03/23 15:29:20 christos Exp $
> +# $File: console,v 1.25 2016/04/18 20:22:10 christos Exp $
> # Console game magic
> # Toby Deshane <hac at shoelace.digivill.net>
>
> @@ -53,7 +53,7 @@
> # so most of the data isn't easily parseable.
> #
> 0 string UNIF
> -4 lelong <16 UNIF v%d format NES ROM image
> +>4 lelong <16 UNIF v%d format NES ROM image
>
> #------------------------------------------------------------------------------
> # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format
>
> Modified: vendor/file/dist/magic/Magdir/os2
> ==============================================================================
> --- vendor/file/dist/magic/Magdir/os2 Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/magic/Magdir/os2 Sat May 14 05:25:47 2016 (r299716)
> @@ -1,12 +1,12 @@
>
> #------------------------------------------------------------------------------
> -# $File: os2,v 1.8 2015/01/05 00:17:13 christos Exp $
> +# $File: os2,v 1.9 2016/05/11 15:51:57 christos Exp $
> # os2: file(1) magic for OS/2 files
> #
>
> # Provided 1998/08/22 by
> # David Mediavilla <davidme.news at REMOVEIFNOTSPAMusa.net>
> -1 search/1 InternetShortcut MS Windows 95 Internet shortcut text
> +1 search/100 InternetShortcut MS Windows 95 Internet shortcut text
> >17 search/100 URL= (URL=<
> >>&0 string x \b%s>)
>
>
> Modified: vendor/file/dist/magic/Magdir/xenix
> ==============================================================================
> --- vendor/file/dist/magic/Magdir/xenix Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/magic/Magdir/xenix Sat May 14 05:25:47 2016 (r299716)
> @@ -1,6 +1,6 @@
>
> #------------------------------------------------------------------------------
> -# $File: xenix,v 1.9 2009/09/19 16:28:13 christos Exp $
> +# $File: xenix,v 1.10 2016/04/19 18:14:19 christos Exp $
> # xenix: file(1) magic for Microsoft Xenix
> #
> # "Middle model" stuff, and "Xenix 8086 relocatable or 80286 small
> @@ -12,7 +12,26 @@
> # XXX - "x.out" collides with PDP-11 archives
> #
> 0 string core core file (Xenix)
> -0 byte 0x80 8086 relocatable (Microsoft)
> +# URL: http://www.polarhome.com/service/man/?qf=86rel&tf=2&of=Xenix
> +# Reference: http://www.azillionmonkeys.com/qed/Omfg.pdf
> +# Update: Joerg Jenderek
> +# recordtype~TranslatorHEADerRecord
> +0 byte 0x80
> +# GRR: line above is too general as it catches also Extensible storage engine DataBase
> +# skip examples like GENA.SND Switch.Snd by looking for record length maximal 1024-3
> +>1 uleshort <1022
> +# skip examples like GAME.PICTURE Strange.Pic by looking for positiv record length
> +>>1 uleshort >0
> +# skip examples like Xtable.Data FRACTAL.GEN SHR.VIEW by looking for positiv string length
> +>>>3 ubyte >0
> +# skip examples like OMBRE.6 with "UUUUUU" by looking for filename like "hello.c"
> +>>>>4 regex [a-zA-Z_/]{1,8}[.] 8086 relocatable (Microsoft)
> +#!:mime application/octet-stream
> +!:mime application/x-object
> +!:ext o/a
> +>>>>>3 pstring x \b, "%s"
> +# checksum
> +#>>>>>(3.b+4) ubyte x \b, checksum 0x%2.2x
> 0 leshort 0xff65 x.out
> >2 string __.SYMDEF randomized
> >0 byte x archive
>
> Modified: vendor/file/dist/src/ascmagic.c
> ==============================================================================
> --- vendor/file/dist/src/ascmagic.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/ascmagic.c Sat May 14 05:25:47 2016 (r299716)
> @@ -35,7 +35,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: ascmagic.c,v 1.94 2016/03/31 17:51:12 christos Exp $")
> +FILE_RCSID("@(#)$File: ascmagic.c,v 1.95 2016/05/03 16:10:37 christos Exp $")
> #endif /* lint */
>
> #include "magic.h"
> @@ -79,9 +79,6 @@ file_ascmagic(struct magic_set *ms, cons
> const char *code_mime = NULL;
> const char *type = NULL;
>
> - if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION))
> - return 0;
> -
> nbytes = trim_nuls(buf, nbytes);
>
> /* If file doesn't look like any sort of text, give up. */
> @@ -123,9 +120,6 @@ file_ascmagic_with_encoding(struct magic
> size_t last_line_end = (size_t)-1;
> int has_long_lines = 0;
>
> - if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION))
> - return 0;
> -
> nbytes = trim_nuls(buf, nbytes);
>
> /* If we have fewer than 2 bytes, give up. */
> @@ -150,7 +144,11 @@ file_ascmagic_with_encoding(struct magic
> (size_t)(utf8_end - utf8_buf), NULL, NULL,
> TEXTTEST, text)) == 0)
> rv = -1;
> + if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)))
> + return rv == -1 ? 0 : 1;
> }
> + if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)))
> + return 0;
>
> /* Now try to discover other details about the file. */
> for (i = 0; i < ulen; i++) {
>
> Modified: vendor/file/dist/src/cdf.c
> ==============================================================================
> --- vendor/file/dist/src/cdf.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/cdf.c Sat May 14 05:25:47 2016 (r299716)
> @@ -35,7 +35,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: cdf.c,v 1.76 2015/02/28 00:18:02 christos Exp $")
> +FILE_RCSID("@(#)$File: cdf.c,v 1.80 2016/05/06 15:17:10 christos Exp $")
> #endif
>
> #include <assert.h>
> @@ -267,13 +267,32 @@ cdf_unpack_dir(cdf_directory_t *d, char
> }
>
> static int
> +cdf_zero_stream(cdf_stream_t *scn)
> +{
> + scn->sst_len = 0;
> + scn->sst_dirlen = 0;
> + scn->sst_ss = 0;
> + free(scn->sst_tab);
> + scn->sst_tab = NULL;
> + return -1;
> +}
> +
> +static size_t
> +cdf_check_stream(const cdf_stream_t *sst, const cdf_header_t *h)
> +{
> + size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
> + CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
> + assert(ss == sst->sst_ss);
> + return sst->sst_ss;
> +}
> +
> +static int
> cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
> const void *p, size_t tail, int line)
> {
> const char *b = (const char *)sst->sst_tab;
> const char *e = ((const char *)p) + tail;
> - size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
> - CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
> + size_t ss = cdf_check_stream(sst, h);
> /*LINTED*/(void)&line;
> if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
> return 0;
> @@ -290,10 +309,8 @@ cdf_read(const cdf_info_t *info, off_t o
> {
> size_t siz = (size_t)off + len;
>
> - if ((off_t)(off + len) != (off_t)siz) {
> - errno = EINVAL;
> - return -1;
> - }
> + if ((off_t)(off + len) != (off_t)siz)
> + goto out;
>
> if (info->i_buf != NULL && info->i_len >= siz) {
> (void)memcpy(buf, &info->i_buf[off], len);
> @@ -301,12 +318,15 @@ cdf_read(const cdf_info_t *info, off_t o
> }
>
> if (info->i_fd == -1)
> - return -1;
> + goto out;
>
> if (pread(info->i_fd, buf, len, off) != (ssize_t)len)
> return -1;
>
> return (ssize_t)len;
> +out:
> + errno = EINVAL;
> + return -1;
> }
>
> int
> @@ -363,11 +383,14 @@ cdf_read_short_sector(const cdf_stream_t
> DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
> SIZE_T_FORMAT "u\n",
> pos + len, CDF_SEC_SIZE(h) * sst->sst_len));
> - return -1;
> + goto out;
> }
> (void)memcpy(((char *)buf) + offs,
> ((const char *)sst->sst_tab) + pos, len);
> return len;
> +out:
> + errno = EFTYPE;
> + return -1;
> }
>
> /*
> @@ -421,8 +444,7 @@ cdf_read_sat(const cdf_info_t *info, cdf
> goto out;
> if (j >= CDF_LOOP_LIMIT) {
> DPRINTF(("Reading master sector loop limit"));
> - errno = EFTYPE;
> - goto out2;
> + goto out3;
> }
> if (cdf_read_sector(info, msa, 0, ss, h, mid) != (ssize_t)ss) {
> DPRINTF(("Reading master sector %d", mid));
> @@ -435,8 +457,7 @@ cdf_read_sat(const cdf_info_t *info, cdf
> if (i >= sat->sat_len) {
> DPRINTF(("Out of bounds reading MSA %" SIZE_T_FORMAT
> "u >= %" SIZE_T_FORMAT "u", i, sat->sat_len));
> - errno = EFTYPE;
> - goto out2;
> + goto out3;
> }
> if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h,
> sec) != (ssize_t)ss) {
> @@ -451,6 +472,8 @@ out:
> sat->sat_len = i;
> free(msa);
> return 0;
> +out3:
> + errno = EFTYPE;
> out2:
> free(msa);
> out1:
> @@ -476,23 +499,24 @@ cdf_count_chain(const cdf_sat_t *sat, cd
> DPRINTF((" %d", sid));
> if (j >= CDF_LOOP_LIMIT) {
> DPRINTF(("Counting chain loop limit"));
> - errno = EFTYPE;
> - return (size_t)-1;
> + goto out;
> }
> if (sid >= maxsector) {
> DPRINTF(("Sector %d >= %d\n", sid, maxsector));
> - errno = EFTYPE;
> - return (size_t)-1;
> + goto out;
> }
> sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
> }
> if (i == 0) {
> DPRINTF((" none, sid: %d\n", sid));
> - return (size_t)-1;
> + goto out;
>
> }
> DPRINTF(("\n"));
> return i;
> +out:
> + errno = EFTYPE;
> + return (size_t)-1;
> }
>
> int
> @@ -501,27 +525,27 @@ cdf_read_long_sector_chain(const cdf_inf
> {
> size_t ss = CDF_SEC_SIZE(h), i, j;
> ssize_t nr;
> + scn->sst_tab = NULL;
> scn->sst_len = cdf_count_chain(sat, sid, ss);
> scn->sst_dirlen = len;
> + scn->sst_ss = ss;
>
> if (scn->sst_len == (size_t)-1)
> - return -1;
> + goto out;
>
> scn->sst_tab = calloc(scn->sst_len, ss);
> if (scn->sst_tab == NULL)
> - return -1;
> + return cdf_zero_stream(scn);
>
> for (j = i = 0; sid >= 0; i++, j++) {
> if (j >= CDF_LOOP_LIMIT) {
> DPRINTF(("Read long sector chain loop limit"));
> - errno = EFTYPE;
> goto out;
> }
> if (i >= scn->sst_len) {
> DPRINTF(("Out of bounds reading long sector chain "
> "%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
> scn->sst_len));
> - errno = EFTYPE;
> goto out;
> }
> if ((nr = cdf_read_sector(info, scn->sst_tab, i * ss, ss, h,
> @@ -537,8 +561,8 @@ cdf_read_long_sector_chain(const cdf_inf
> }
> return 0;
> out:
> - free(scn->sst_tab);
> - return -1;
> + errno = EFTYPE;
> + return cdf_zero_stream(scn);
> }
>
> int
> @@ -547,27 +571,27 @@ cdf_read_short_sector_chain(const cdf_he
> cdf_secid_t sid, size_t len, cdf_stream_t *scn)
> {
> size_t ss = CDF_SHORT_SEC_SIZE(h), i, j;
> - scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));
> + scn->sst_tab = NULL;
> + scn->sst_len = cdf_count_chain(ssat, sid, ss);
> scn->sst_dirlen = len;
> + scn->sst_ss = ss;
>
> if (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)
> - return -1;
> + goto out;
>
> scn->sst_tab = calloc(scn->sst_len, ss);
> if (scn->sst_tab == NULL)
> - return -1;
> + return cdf_zero_stream(scn);
>
> for (j = i = 0; sid >= 0; i++, j++) {
> if (j >= CDF_LOOP_LIMIT) {
> DPRINTF(("Read short sector chain loop limit"));
> - errno = EFTYPE;
> goto out;
> }
> if (i >= scn->sst_len) {
> DPRINTF(("Out of bounds reading short sector chain "
> "%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n",
> i, scn->sst_len));
> - errno = EFTYPE;
> goto out;
> }
> if (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,
> @@ -579,8 +603,8 @@ cdf_read_short_sector_chain(const cdf_he
> }
> return 0;
> out:
> - free(scn->sst_tab);
> - return -1;
> + errno = EFTYPE;
> + return cdf_zero_stream(scn);
> }
>
> int
> @@ -625,7 +649,6 @@ cdf_read_dir(const cdf_info_t *info, con
> for (j = i = 0; i < ns; i++, j++) {
> if (j >= CDF_LOOP_LIMIT) {
> DPRINTF(("Read dir loop limit"));
> - errno = EFTYPE;
> goto out;
> }
> if (cdf_read_sector(info, buf, 0, ss, h, sid) != (ssize_t)ss) {
> @@ -646,6 +669,7 @@ cdf_read_dir(const cdf_info_t *info, con
> out:
> free(dir->dir_tab);
> free(buf);
> + errno = EFTYPE;
> return -1;
> }
>
> @@ -658,36 +682,37 @@ cdf_read_ssat(const cdf_info_t *info, co
> size_t ss = CDF_SEC_SIZE(h);
> cdf_secid_t sid = h->h_secid_first_sector_in_short_sat;
>
> + ssat->sat_tab = NULL;
> ssat->sat_len = cdf_count_chain(sat, sid, CDF_SEC_SIZE(h));
> if (ssat->sat_len == (size_t)-1)
> - return -1;
> + goto out;
>
> ssat->sat_tab = CAST(cdf_secid_t *, calloc(ssat->sat_len, ss));
> if (ssat->sat_tab == NULL)
> - return -1;
> + goto out1;
>
> for (j = i = 0; sid >= 0; i++, j++) {
> if (j >= CDF_LOOP_LIMIT) {
> DPRINTF(("Read short sat sector loop limit"));
> - errno = EFTYPE;
> goto out;
> }
> if (i >= ssat->sat_len) {
> DPRINTF(("Out of bounds reading short sector chain "
> "%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
> ssat->sat_len));
> - errno = EFTYPE;
> goto out;
> }
> if (cdf_read_sector(info, ssat->sat_tab, i * ss, ss, h, sid) !=
> (ssize_t)ss) {
> DPRINTF(("Reading short sat sector %d", sid));
> - goto out;
> + goto out1;
> }
> sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
> }
> return 0;
> out:
> + errno = EFTYPE;
> +out1:
> free(ssat->sat_tab);
> return -1;
> }
> @@ -715,13 +740,13 @@ cdf_read_short_stream(const cdf_info_t *
> if (d->d_stream_first_sector < 0)
> goto out;
>
> - return cdf_read_long_sector_chain(info, h, sat,
> + return cdf_read_long_sector_chain(info, h, sat,
> d->d_stream_first_sector, d->d_size, scn);
> out:
> scn->sst_tab = NULL;
> - scn->sst_len = 0;
> - scn->sst_dirlen = 0;
> - return 0;
> + (void)cdf_zero_stream(scn);
> + errno = EFTYPE;
> + return -1;
> }
>
> static int
> @@ -750,8 +775,10 @@ cdf_read_user_stream(const cdf_info_t *i
> const cdf_directory_t *d;
> int i = cdf_find_stream(dir, name, CDF_DIR_TYPE_USER_STREAM);
>
> - if (i <= 0)
> + if (i <= 0) {
> + memset(scn, 0, sizeof(*scn));
> return -1;
> + }
>
> d = &dir->dir_tab[i - 1];
> return cdf_read_sector_chain(info, h, sat, ssat, sst,
> @@ -824,7 +851,7 @@ cdf_read_property_info(const cdf_stream_
> malloc(*maxcount * sizeof(*inp)));
> }
> if (inp == NULL)
> - goto out;
> + goto out1;
> *info = inp;
> inp += *count;
> *count += sh.sh_properties;
> @@ -931,7 +958,7 @@ cdf_read_property_info(const cdf_stream_
> inp = CAST(cdf_property_info_t *,
> realloc(*info, *maxcount * sizeof(*inp)));
> if (inp == NULL)
> - goto out;
> + goto out1;
> *info = inp;
> inp = *info + nelem;
> }
> @@ -976,6 +1003,8 @@ cdf_read_property_info(const cdf_stream_
> }
> return 0;
> out:
> + errno = EFTYPE;
> +out1:
> free(*info);
> return -1;
> }
> @@ -1022,8 +1051,7 @@ int
> cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,
> cdf_catalog_t **cat)
> {
> - size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
> - CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
> + size_t ss = cdf_check_stream(sst, h);
> const char *b = CAST(const char *, sst->sst_tab);
> const char *eb = b + ss * sst->sst_len;
> size_t nr, i, j, k;
> @@ -1043,6 +1071,8 @@ cdf_unpack_catalog(const cdf_header_t *h
> nr--;
> *cat = CAST(cdf_catalog_t *,
> malloc(sizeof(cdf_catalog_t) + nr * sizeof(*ce)));
> + if (*cat == NULL)
> + return -1;
> ce = (*cat)->cat_e;
> memset(ce, 0, nr * sizeof(*ce));
> b = CAST(const char *, sst->sst_tab);
> @@ -1245,8 +1275,7 @@ cdf_dump(const void *v, size_t len)
> void
> cdf_dump_stream(const cdf_header_t *h, const cdf_stream_t *sst)
> {
> - size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
> - CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
> + size_t ss = sst->sst_ss;
> cdf_dump(sst->sst_tab, ss * sst->sst_len);
> }
>
>
> Modified: vendor/file/dist/src/cdf.h
> ==============================================================================
> --- vendor/file/dist/src/cdf.h Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/cdf.h Sat May 14 05:25:47 2016 (r299716)
> @@ -129,6 +129,7 @@ typedef struct {
> void *sst_tab;
> size_t sst_len;
> size_t sst_dirlen;
> + size_t sst_ss;
> } cdf_stream_t;
>
> typedef struct {
> @@ -277,7 +278,7 @@ typedef struct {
>
> typedef struct {
> size_t cat_num;
> - cdf_catalog_entry_t cat_e[0];
> + cdf_catalog_entry_t cat_e[1];
> } cdf_catalog_t;
>
> struct timespec;
>
> Modified: vendor/file/dist/src/compress.c
> ==============================================================================
> --- vendor/file/dist/src/compress.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/compress.c Sat May 14 05:25:47 2016 (r299716)
> @@ -35,7 +35,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: compress.c,v 1.93 2016/03/31 17:51:12 christos Exp $")
> +FILE_RCSID("@(#)$File: compress.c,v 1.96 2016/04/20 00:00:26 christos Exp $")
> #endif
>
> #include "magic.h"
> @@ -187,7 +187,7 @@ file_zmagic(struct magic_set *ms, int fd
> size_t i, nsz;
> char *rbuf;
> file_pushbuf_t *pb;
> - int rv = 0;
> + int urv, prv, rv = 0;
> int mime = ms->flags & MAGIC_MIME;
> #ifdef HAVE_SIGNAL_H
> sig_t osigpipe;
> @@ -214,22 +214,22 @@ file_zmagic(struct magic_set *ms, int fd
> if (!zm)
> continue;
> nsz = nbytes;
> - rv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz);
> - DPRINTF("uncompressbuf = %d, %s, %zu\n", rv, (char *)newbuf,
> + urv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz);
> + DPRINTF("uncompressbuf = %d, %s, %zu\n", urv, (char *)newbuf,
> nsz);
> - switch (rv) {
> + switch (urv) {
> case OKDATA:
> case ERRDATA:
>
> ms->flags &= ~MAGIC_COMPRESS;
> - if (rv == ERRDATA)
> - rv = file_printf(ms, "%s ERROR: %s",
> + if (urv == ERRDATA)
> + prv = file_printf(ms, "%s ERROR: %s",
> methodname(i), newbuf);
> else
> - rv = file_buffer(ms, -1, name, newbuf, nsz);
> - if (rv == -1)
> + prv = file_buffer(ms, -1, name, newbuf, nsz);
> + if (prv == -1)
> goto error;
> - DPRINTF("rv = %d\n", rv);
> + rv = 1;
> if ((ms->flags & MAGIC_COMPRESS_TRANSP) != 0)
> goto out;
> if (mime != MAGIC_MIME && mime != 0)
> @@ -239,6 +239,10 @@ file_zmagic(struct magic_set *ms, int fd
> goto error;
> if ((pb = file_push_buffer(ms)) == NULL)
> goto error;
> + /*
> + * XXX: If file_buffer fails here, we overwrite
> + * the compressed text. FIXME.
> + */
> if (file_buffer(ms, -1, NULL, buf, nbytes) == -1)
> goto error;
> if ((rbuf = file_pop_buffer(ms, pb)) != NULL) {
> @@ -250,16 +254,20 @@ file_zmagic(struct magic_set *ms, int fd
> }
> if (!mime && file_printf(ms, ")") == -1)
> goto error;
> - goto out;
> + /*FALLTHROUGH*/
> case NODATA:
> - goto out;
> + break;
> default:
> abort();
> + /*NOTREACHED*/
> + error:
> + rv = -1;
> + break;
> }
> }
> out:
> - rv = 1;
> -error:
> + DPRINTF("rv = %d\n", rv);
> +
> #ifdef HAVE_SIGNAL_H
> (void)signal(SIGPIPE, osigpipe);
> #endif
>
> Modified: vendor/file/dist/src/der.c
> ==============================================================================
> --- vendor/file/dist/src/der.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/der.c Sat May 14 05:25:47 2016 (r299716)
> @@ -35,7 +35,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: der.c,v 1.4 2016/03/21 23:04:40 christos Exp $")
> +FILE_RCSID("@(#)$File: der.c,v 1.6 2016/04/21 14:26:03 christos Exp $")
> #endif
> #endif
>
> @@ -44,7 +44,6 @@ FILE_RCSID("@(#)$File: der.c,v 1.4 2016/
> #include <sys/mman.h>
>
> #include <stdio.h>
> -#include <err.h>
> #include <fcntl.h>
> #include <stdlib.h>
> #include <string.h>
> @@ -53,6 +52,8 @@ FILE_RCSID("@(#)$File: der.c,v 1.4 2016/
> #ifndef TEST_DER
> #include "magic.h"
> #include "der.h"
> +#else
> +#include <err.h>
> #endif
>
> #define DER_BAD ((uint32_t)-1)
> @@ -61,11 +62,15 @@ FILE_RCSID("@(#)$File: der.c,v 1.4 2016/
> #define DER_CLASS_APPLICATION 1
> #define DER_CLASS_CONTEXT 2
> #define DER_CLASS_PRIVATE 3
> +#ifdef DEBUG_DER
> static const char der_class[] = "UACP";
> +#endif
>
> #define DER_TYPE_PRIMITIVE 0
> #define DER_TYPE_CONSTRUCTED 1
> +#ifdef DEBUG_DER
> static const char der_type[] = "PC";
> +#endif
>
> #define DER_TAG_EOC 0x00
> #define DER_TAG_BOOLEAN 0x01
>
> Modified: vendor/file/dist/src/magic.c
> ==============================================================================
> --- vendor/file/dist/src/magic.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/magic.c Sat May 14 05:25:47 2016 (r299716)
> @@ -33,7 +33,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: magic.c,v 1.97 2016/03/31 17:51:12 christos Exp $")
> +FILE_RCSID("@(#)$File: magic.c,v 1.99 2016/05/03 16:09:38 christos Exp $")
> #endif /* lint */
>
> #include "magic.h"
> @@ -523,9 +523,11 @@ file_or_fd(struct magic_set *ms, const c
> rv = 0;
> done:
> free(buf);
> - if (pos != (off_t)-1)
> - (void)lseek(fd, pos, SEEK_SET);
> - close_and_restore(ms, inname, fd, &sb);
> + if (fd != -1) {
> + if (pos != (off_t)-1)
> + (void)lseek(fd, pos, SEEK_SET);
> + close_and_restore(ms, inname, fd, &sb);
> + }
> out:
> return rv == 0 ? file_getbuffer(ms) : NULL;
> }
>
> Modified: vendor/file/dist/src/magic.h
> ==============================================================================
> --- vendor/file/dist/src/magic.h Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/magic.h Sat May 14 05:25:47 2016 (r299716)
> @@ -80,7 +80,7 @@
> #define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
> #define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
>
> -#define MAGIC_VERSION 525 /* This implementation */
> +#define MAGIC_VERSION 526 /* This implementation */
>
>
> #ifdef __cplusplus
> @@ -114,7 +114,7 @@ int magic_errno(magic_t);
> #define MAGIC_PARAM_ELF_SHNUM_MAX 3
> #define MAGIC_PARAM_ELF_NOTES_MAX 4
> #define MAGIC_PARAM_REGEX_MAX 5
> -#define MAGIC_PARAM_BYTES_MAX 6
> +#define MAGIC_PARAM_BYTES_MAX 6
>
> int magic_setparam(magic_t, int, const void *);
> int magic_getparam(magic_t, int, void *);
>
> Modified: vendor/file/dist/src/magic.h.in
> ==============================================================================
> --- vendor/file/dist/src/magic.h.in Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/magic.h.in Sat May 14 05:25:47 2016 (r299716)
> @@ -114,6 +114,7 @@ int magic_errno(magic_t);
> #define MAGIC_PARAM_ELF_SHNUM_MAX 3
> #define MAGIC_PARAM_ELF_NOTES_MAX 4
> #define MAGIC_PARAM_REGEX_MAX 5
> +#define MAGIC_PARAM_BYTES_MAX 6
>
> int magic_setparam(magic_t, int, const void *);
> int magic_getparam(magic_t, int, void *);
>
> Modified: vendor/file/dist/src/readcdf.c
> ==============================================================================
> --- vendor/file/dist/src/readcdf.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/readcdf.c Sat May 14 05:25:47 2016 (r299716)
> @@ -26,7 +26,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: readcdf.c,v 1.56 2016/03/03 22:20:03 christos Exp $")
> +FILE_RCSID("@(#)$File: readcdf.c,v 1.57 2016/05/03 16:08:49 christos Exp $")
> #endif
>
> #include <assert.h>
> @@ -373,7 +373,7 @@ cdf_file_catalog_info(struct magic_set *
> dir, "Catalog", scn)) == -1)
> return i;
> #ifdef CDF_DEBUG
> - cdf_dump_catalog(&h, &scn);
> + cdf_dump_catalog(&h, scn);
> #endif
> if ((i = cdf_file_catalog(ms, h, scn)) == -1)
> return -1;
>
> Modified: vendor/file/dist/src/softmagic.c
> ==============================================================================
> --- vendor/file/dist/src/softmagic.c Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/src/softmagic.c Sat May 14 05:25:47 2016 (r299716)
> @@ -32,7 +32,7 @@
> #include "file.h"
>
> #ifndef lint
> -FILE_RCSID("@(#)$File: softmagic.c,v 1.230 2016/04/18 15:10:34 christos Exp $")
> +FILE_RCSID("@(#)$File: softmagic.c,v 1.231 2016/04/21 15:23:31 christos Exp $")
> #endif /* lint */
>
> #include "magic.h"
>
> Modified: vendor/file/dist/tests/Makefile.am
> ==============================================================================
> --- vendor/file/dist/tests/Makefile.am Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/tests/Makefile.am Sat May 14 05:25:47 2016 (r299716)
> @@ -13,4 +13,4 @@ issue311docx.testfile
> T = $(top_srcdir)/tests
> check-local:
> MAGIC=$(top_builddir)/magic/magic ./test
> - for i in $T/*.testfile; do echo Running test: $$i; MAGIC=$(top_builddir)/magic/magic ./test $$i $${i%%.testfile}.result; done
> + set -e; for i in $T/*.testfile; do echo Running test: $$i; TZ=UTC MAGIC=$(top_builddir)/magic/magic ./test $$i $${i%%.testfile}.result; done
>
> Modified: vendor/file/dist/tests/Makefile.in
> ==============================================================================
> --- vendor/file/dist/tests/Makefile.in Sat May 14 05:00:17 2016 (r299715)
> +++ vendor/file/dist/tests/Makefile.in Sat May 14 05:25:47 2016 (r299716)
> @@ -608,7 +608,7 @@ uninstall-am:
>
> check-local:
> MAGIC=$(top_builddir)/magic/magic ./test
> - for i in $T/*.testfile; do echo Running test: $$i; MAGIC=$(top_builddir)/magic/magic ./test $$i $${i%%.testfile}.result; done
> + set -e; for i in $T/*.testfile; do echo Running test: $$i; TZ=UTC MAGIC=$(top_builddir)/magic/magic ./test $$i $${i%%.testfile}.result; done
>
> # Tell versions [3.59,3.63) of GNU make to not export all variables.
> # Otherwise a system limit (for SysV at least) may be exceeded.
> _______________________________________________
> svn-src-all at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe at freebsd.org"
More information about the svn-src-vendor
mailing list