merge local changes between 5.39 and 5.40 and add magic entries from HEAD.
This commit is contained in:
parent
25f16eeab3
commit
d87b003935
30
external/bsd/file/dist/ChangeLog
vendored
30
external/bsd/file/dist/ChangeLog
vendored
@ -1,3 +1,33 @@
|
||||
2021-03-30 20:21 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* release 5.40
|
||||
|
||||
2021-02-05 16:31 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* PR/234: Add limit to the number of bytes to scan for encoding
|
||||
* PR/230: Fix /T (trim flag) for regex
|
||||
|
||||
2021-02-01 12:31 Christos Zoulas <christos@zoulas.com>
|
||||
* PR/77: Trim trailing separator.
|
||||
|
||||
2020-12-17 15:44 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* PR/211: Convert system read errors from corrupt ELF
|
||||
files into human readable error messages
|
||||
|
||||
2020-12-08 16:24 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* fix multithreaded decompression file descriptor issue
|
||||
by using close-on-exec (Denys Vlasenko)
|
||||
|
||||
2020-06-27 11:58 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Exclude surrogate pairs from utf-8 detection (Michael Liu)
|
||||
|
||||
2020-06-25 12:53 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Include # to the list of ignored format chars (Werner Fink)
|
||||
|
||||
2020-06-14 20:02 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* release 5.39
|
||||
|
8
external/bsd/file/dist/config.guess
vendored
8
external/bsd/file/dist/config.guess
vendored
@ -188,10 +188,8 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
||||
sh3el) machine=shl-unknown ;;
|
||||
sh3eb) machine=sh-unknown ;;
|
||||
sh5el) machine=sh5le-unknown ;;
|
||||
earm*)
|
||||
arch="${UNAME_MACHINE_ARCH#e}"
|
||||
arch="${arch%eb}"
|
||||
arch="${arch%hf}"
|
||||
earmv*)
|
||||
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
|
||||
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
|
||||
machine="${arch}${endian}"-unknown
|
||||
;;
|
||||
@ -222,7 +220,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
||||
# Determine ABI tags.
|
||||
case "$UNAME_MACHINE_ARCH" in
|
||||
earm*)
|
||||
expr='s/v[0-9]//;s/earm/-eabi/;s/eb$//'
|
||||
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
|
||||
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
|
||||
;;
|
||||
esac
|
||||
|
3
external/bsd/file/dist/config.h.in
vendored
3
external/bsd/file/dist/config.h.in
vendored
@ -125,6 +125,9 @@
|
||||
/* Define to 1 if you have the `newlocale' function. */
|
||||
#undef HAVE_NEWLOCALE
|
||||
|
||||
/* Define to 1 if you have the `pipe2' function. */
|
||||
#undef HAVE_PIPE2
|
||||
|
||||
/* Define to 1 if you have the `pread' function. */
|
||||
#undef HAVE_PREAD
|
||||
|
||||
|
22
external/bsd/file/dist/configure
vendored
22
external/bsd/file/dist/configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for file 5.39.
|
||||
# Generated by GNU Autoconf 2.69 for file 5.40.
|
||||
#
|
||||
# Report bugs to <christos@astron.com>.
|
||||
#
|
||||
@ -590,8 +590,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='file'
|
||||
PACKAGE_TARNAME='file'
|
||||
PACKAGE_VERSION='5.39'
|
||||
PACKAGE_STRING='file 5.39'
|
||||
PACKAGE_VERSION='5.40'
|
||||
PACKAGE_STRING='file 5.40'
|
||||
PACKAGE_BUGREPORT='christos@astron.com'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -1338,7 +1338,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.39 to adapt to many kinds of systems.
|
||||
\`configure' configures file 5.40 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1408,7 +1408,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of file 5.39:";;
|
||||
short | recursive ) echo "Configuration of file 5.40:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1531,7 +1531,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
file configure 5.39
|
||||
file configure 5.40
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -2187,7 +2187,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.39, which was
|
||||
It was created by file $as_me 5.40, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -3075,7 +3075,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='file'
|
||||
VERSION='5.39'
|
||||
VERSION='5.40'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@ -14721,7 +14721,7 @@ fi
|
||||
fi
|
||||
|
||||
|
||||
for ac_func in strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem
|
||||
for ac_func in strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
@ -15745,7 +15745,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# 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.39, which was
|
||||
This file was extended by file $as_me 5.40, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -15811,7 +15811,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.39
|
||||
file config.status 5.40
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
4
external/bsd/file/dist/configure.ac
vendored
4
external/bsd/file/dist/configure.ac
vendored
@ -1,5 +1,5 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT([file],[5.39],[christos@astron.com])
|
||||
AC_INIT([file],[5.40],[christos@astron.com])
|
||||
AM_INIT_AUTOMAKE([subdir-objects foreign])
|
||||
AM_MAINTAINER_MODE(disable)
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
@ -167,7 +167,7 @@ else
|
||||
fi])
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem)
|
||||
AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2)
|
||||
|
||||
dnl Provide implementation of some required functions if necessary
|
||||
AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
|
||||
|
65
external/bsd/file/dist/doc/file.1
vendored
65
external/bsd/file/dist/doc/file.1
vendored
@ -1,7 +1,7 @@
|
||||
.\" $NetBSD: file.1,v 1.25 2020/06/15 00:37:24 christos Exp $
|
||||
.\" $NetBSD: file.1,v 1.26 2021/04/09 19:11:41 christos Exp $
|
||||
.\"
|
||||
.\" $File: file.man,v 1.140 2020/06/07 17:41:07 christos Exp $
|
||||
.Dd June 7, 2020
|
||||
.\" $File: file.man,v 1.144 2021/02/05 22:08:31 christos Exp $
|
||||
.Dd February 5, 2021
|
||||
.Dt FILE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -29,7 +29,7 @@
|
||||
.Nm
|
||||
.Op Fl Fl help
|
||||
.Sh DESCRIPTION
|
||||
This manual page documents version 5.39 of the
|
||||
This manual page documents version 5.40 of the
|
||||
.Nm
|
||||
command.
|
||||
.Pp
|
||||
@ -61,7 +61,7 @@ or non-printable).
|
||||
Exceptions are well-known file formats (core files, tar archives)
|
||||
that are known to contain binary data.
|
||||
When modifying magic files or the program itself, make sure to
|
||||
.Em "preserve these keywords" .
|
||||
.Em preserve these keywords .
|
||||
Users depend on knowing that all the readable files in a directory
|
||||
have the word
|
||||
.Dq text
|
||||
@ -93,14 +93,14 @@ and possibly
|
||||
.In exec.h
|
||||
in the standard include directory.
|
||||
These files have a
|
||||
.Dq "magic number"
|
||||
.Dq magic number
|
||||
stored in a particular place
|
||||
near the beginning of the file that tells the
|
||||
.Tn UNIX
|
||||
operating system
|
||||
that the file is a binary executable, and which of several types thereof.
|
||||
The concept of a
|
||||
.Dq "magic"
|
||||
.Dq magic number
|
||||
has been applied by extension to data files.
|
||||
Any file with some invariant identifier at a small fixed
|
||||
offset into the file can usually be described in this way.
|
||||
@ -170,7 +170,9 @@ in any of the character sets listed above is simply said to be
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl Fl apple
|
||||
Causes the file command to output the file type and creator code as
|
||||
Causes the
|
||||
.Nm
|
||||
command to output the file type and creator code as
|
||||
used by older MacOS versions.
|
||||
The code consists of eight letters,
|
||||
the first describing the file type, the latter the creator.
|
||||
@ -186,7 +188,7 @@ output file that contains a pre-parsed version of the magic file or directory.
|
||||
Cause a checking printout of the parsed form of the magic file.
|
||||
This is usually used in conjunction with the
|
||||
.Fl m
|
||||
flag to debug a new magic file before installing it.
|
||||
option to debug a new magic file before installing it.
|
||||
.It Fl d
|
||||
Prints internal debugging information to stderr.
|
||||
.It Fl E
|
||||
@ -238,7 +240,7 @@ Like
|
||||
but ignore tests that
|
||||
.Nm
|
||||
does not know about.
|
||||
This is intended for compatilibity with older versions of
|
||||
This is intended for compatibility with older versions of
|
||||
.Nm .
|
||||
.It Fl Fl extension
|
||||
Print a slash-separated list of valid extensions for the file type found.
|
||||
@ -272,13 +274,15 @@ the list of files, like:
|
||||
instead of:
|
||||
.Dq Fl f Ar namefile Fl F Ar @ .
|
||||
.It Fl h , Fl Fl no-dereference
|
||||
option causes symlinks not to be followed
|
||||
This option causes symlinks not to be followed
|
||||
(on systems that support symbolic links).
|
||||
This is the default if the environment variable
|
||||
.Dv POSIXLY_CORRECT
|
||||
is not defined.
|
||||
.It Fl i , Fl Fl mime
|
||||
Causes the file command to output mime type strings rather than the more
|
||||
Causes the
|
||||
.Nm
|
||||
command to output mime type strings rather than the more
|
||||
traditional human readable ones.
|
||||
Thus it may say
|
||||
.Sq text/plain; charset=us-ascii
|
||||
@ -308,7 +312,7 @@ which is used for the matching (see also the
|
||||
.Fl k
|
||||
option).
|
||||
.It Fl L , Fl Fl dereference
|
||||
option causes symlinks to be followed, as the like-named option in
|
||||
This option causes symlinks to be followed, as the like-named option in
|
||||
.Xr ls 1
|
||||
(on systems that support symbolic links).
|
||||
This is the default if the environment variable
|
||||
@ -341,6 +345,7 @@ Set various parameter limits.
|
||||
.It Li elf_notes Ta 256 Ta max ELF notes processed
|
||||
.It Li elf_phnum Ta 2048 Ta max ELF program sections processed
|
||||
.It Li elf_shnum Ta 32768 Ta max ELF sections processed
|
||||
.It Li encoding Ta 65536 Ta max number of bytes to scan for encoding evaluation
|
||||
.It Li indir Ta 50 Ta recursion limit for indirect magic
|
||||
.It Li name Ta 50 Ta use count limit for name/use magic
|
||||
.It Li regex Ta 8192 Ta length limit for regex searches
|
||||
@ -375,11 +380,13 @@ On systems where libseccomp
|
||||
.Pa ( https://github.com/seccomp/libseccomp )
|
||||
is available, the
|
||||
.Fl S
|
||||
flag disables sandboxing which is enabled by default.
|
||||
This option is needed for file to execute external decompressing programs,
|
||||
option disables sandboxing which is enabled by default.
|
||||
This option is needed for
|
||||
.Nm
|
||||
to execute external decompressing programs,
|
||||
i.e. when the
|
||||
.Fl z
|
||||
flag is specified and the built-in decompressors are not available.
|
||||
option is specified and the built-in decompressors are not available.
|
||||
On systems where sandboxing is not available, this option has no effect.
|
||||
.It Fl v , Fl Fl version
|
||||
Print the version of the program and exit.
|
||||
@ -458,9 +465,9 @@ The file type cannot be determined
|
||||
.Sh EXAMPLES
|
||||
.Bd -literal -offset indent
|
||||
$ file file.c file /dev/{wd0a,hda}
|
||||
file.c: C program text
|
||||
file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
|
||||
dynamically linked (uses shared libs), stripped
|
||||
file.c: C program text
|
||||
file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
|
||||
dynamically linked (uses shared libs), stripped
|
||||
/dev/wd0a: block special (0/0)
|
||||
/dev/hda: block special (3/0)
|
||||
|
||||
@ -482,8 +489,8 @@ $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
|
||||
/dev/hda10: empty
|
||||
|
||||
$ file -i file.c file /dev/{wd0a,hda}
|
||||
file.c: text/x-c
|
||||
file: application/x-executable
|
||||
file.c: text/x-c
|
||||
file: application/x-executable
|
||||
/dev/hda: application/x-not-regular-file
|
||||
/dev/wd0a: application/x-not-regular-file
|
||||
|
||||
@ -508,7 +515,7 @@ is that this version treats any white space
|
||||
as a delimiter, so that spaces in pattern strings must be escaped.
|
||||
For example,
|
||||
.Bd -literal -offset indent
|
||||
\*[Gt]10 string language impress\ (imPRESS data)
|
||||
\*[Gt]10 string language impress\ (imPRESS data)
|
||||
.Ed
|
||||
.Pp
|
||||
in an existing magic file would have to be changed to
|
||||
@ -555,7 +562,7 @@ option.
|
||||
To enable execution of external decompressors, one needs to disable
|
||||
sandboxing using the
|
||||
.Fl S
|
||||
flag.
|
||||
option.
|
||||
.Sh MAGIC DIRECTORY
|
||||
The magic file entries have been collected from various sources,
|
||||
mainly USENET, and contributed by various authors.
|
||||
@ -667,7 +674,7 @@ and printing \e012- between entries is clumsy and complicated; refactor
|
||||
and centralize.
|
||||
.Pp
|
||||
Some of the encoding logic is hard-coded in encoding.c and can be moved
|
||||
to the magic files if we had a !:charset annotation
|
||||
to the magic files if we had a !:charset annotation.
|
||||
.Pp
|
||||
Continue to squash all magic bugs.
|
||||
See Debian BTS for a good source.
|
||||
@ -720,9 +727,13 @@ If the offsets specified internally in the file exceed the buffer size
|
||||
.Dv HOWMANY
|
||||
variable in file.h), then we don't seek to that offset, but we give up.
|
||||
It would be better if buffer managements was done when the file descriptor
|
||||
is available so move around the file.
|
||||
One must be careful though because this has performance (and thus security
|
||||
considerations).
|
||||
is available so we can seek around the file.
|
||||
One must be careful though because this has performance and thus security
|
||||
considerations, because one can slow down things by repeateadly seeking.
|
||||
.Pp
|
||||
There is support now for keeping separate buffers and having offsets from
|
||||
the end of the file, but the internal buffer management still needs an
|
||||
overhaul.
|
||||
.Sh AVAILABILITY
|
||||
You can obtain the original author's latest version by anonymous FTP
|
||||
on
|
||||
|
4
external/bsd/file/dist/doc/magic.5
vendored
4
external/bsd/file/dist/doc/magic.5
vendored
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: magic.5,v 1.22 2020/06/15 00:37:24 christos Exp $
|
||||
.\" $NetBSD: magic.5,v 1.23 2021/04/09 19:11:41 christos Exp $
|
||||
.\"
|
||||
.\" $File: magic.man,v 1.98 2020/05/09 18:55:23 christos Exp $
|
||||
.Dd May 9, 2020
|
||||
@ -12,7 +12,7 @@
|
||||
This manual page documents the format of magic files as
|
||||
used by the
|
||||
.Xr file 1
|
||||
command, version 5.39.
|
||||
command, version 5.40.
|
||||
The
|
||||
.Xr file 1
|
||||
command identifies the type of a file using,
|
||||
|
11
external/bsd/file/dist/magic/Makefile.am
vendored
11
external/bsd/file/dist/magic/Makefile.am
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $File: Makefile.am,v 1.157 2020/05/21 16:22:47 christos Exp $
|
||||
# $File: Makefile.am,v 1.166 2021/03/14 16:24:18 christos Exp $
|
||||
#
|
||||
MAGIC_FRAGMENT_BASE = magdir
|
||||
MAGIC_DIR = $(top_srcdir)/magic
|
||||
@ -13,6 +13,7 @@ $(MAGIC_DIR)/Localstuff \
|
||||
$(MAGIC_FRAGMENT_DIR)/acorn \
|
||||
$(MAGIC_FRAGMENT_DIR)/adi \
|
||||
$(MAGIC_FRAGMENT_DIR)/adventure \
|
||||
$(MAGIC_FRAGMENT_DIR)/aes \
|
||||
$(MAGIC_FRAGMENT_DIR)/algol68 \
|
||||
$(MAGIC_FRAGMENT_DIR)/allegro \
|
||||
$(MAGIC_FRAGMENT_DIR)/alliant \
|
||||
@ -33,6 +34,7 @@ $(MAGIC_FRAGMENT_DIR)/assembler \
|
||||
$(MAGIC_FRAGMENT_DIR)/asterix \
|
||||
$(MAGIC_FRAGMENT_DIR)/att3b \
|
||||
$(MAGIC_FRAGMENT_DIR)/audio \
|
||||
$(MAGIC_FRAGMENT_DIR)/avm \
|
||||
$(MAGIC_FRAGMENT_DIR)/basis \
|
||||
$(MAGIC_FRAGMENT_DIR)/beetle \
|
||||
$(MAGIC_FRAGMENT_DIR)/ber \
|
||||
@ -44,6 +46,7 @@ $(MAGIC_FRAGMENT_DIR)/blackberry \
|
||||
$(MAGIC_FRAGMENT_DIR)/blcr \
|
||||
$(MAGIC_FRAGMENT_DIR)/blender \
|
||||
$(MAGIC_FRAGMENT_DIR)/blit \
|
||||
$(MAGIC_FRAGMENT_DIR)/bm \
|
||||
$(MAGIC_FRAGMENT_DIR)/bout \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsdi \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsi \
|
||||
@ -69,6 +72,7 @@ $(MAGIC_FRAGMENT_DIR)/console \
|
||||
$(MAGIC_FRAGMENT_DIR)/convex \
|
||||
$(MAGIC_FRAGMENT_DIR)/coverage \
|
||||
$(MAGIC_FRAGMENT_DIR)/cracklib \
|
||||
$(MAGIC_FRAGMENT_DIR)/crypto \
|
||||
$(MAGIC_FRAGMENT_DIR)/ctags \
|
||||
$(MAGIC_FRAGMENT_DIR)/ctf \
|
||||
$(MAGIC_FRAGMENT_DIR)/cubemap \
|
||||
@ -148,12 +152,14 @@ $(MAGIC_FRAGMENT_DIR)/keepass \
|
||||
$(MAGIC_FRAGMENT_DIR)/kerberos \
|
||||
$(MAGIC_FRAGMENT_DIR)/kicad \
|
||||
$(MAGIC_FRAGMENT_DIR)/kml \
|
||||
$(MAGIC_FRAGMENT_DIR)/lammps \
|
||||
$(MAGIC_FRAGMENT_DIR)/lecter \
|
||||
$(MAGIC_FRAGMENT_DIR)/lex \
|
||||
$(MAGIC_FRAGMENT_DIR)/lif \
|
||||
$(MAGIC_FRAGMENT_DIR)/linux \
|
||||
$(MAGIC_FRAGMENT_DIR)/lisp \
|
||||
$(MAGIC_FRAGMENT_DIR)/llvm \
|
||||
$(MAGIC_FRAGMENT_DIR)/locoscript \
|
||||
$(MAGIC_FRAGMENT_DIR)/lua \
|
||||
$(MAGIC_FRAGMENT_DIR)/luks \
|
||||
$(MAGIC_FRAGMENT_DIR)/m4 \
|
||||
@ -221,11 +227,13 @@ $(MAGIC_FRAGMENT_DIR)/pbf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pbm \
|
||||
$(MAGIC_FRAGMENT_DIR)/pc88 \
|
||||
$(MAGIC_FRAGMENT_DIR)/pc98 \
|
||||
$(MAGIC_FRAGMENT_DIR)/pcjr \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdp \
|
||||
$(MAGIC_FRAGMENT_DIR)/perl \
|
||||
$(MAGIC_FRAGMENT_DIR)/pgf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pgp \
|
||||
$(MAGIC_FRAGMENT_DIR)/pgp-binary-keys \
|
||||
$(MAGIC_FRAGMENT_DIR)/pkgadd \
|
||||
$(MAGIC_FRAGMENT_DIR)/plan9 \
|
||||
$(MAGIC_FRAGMENT_DIR)/plus5 \
|
||||
@ -272,6 +280,7 @@ $(MAGIC_FRAGMENT_DIR)/spectrum \
|
||||
$(MAGIC_FRAGMENT_DIR)/sql \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssh \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssl \
|
||||
$(MAGIC_FRAGMENT_DIR)/statistics \
|
||||
$(MAGIC_FRAGMENT_DIR)/sun \
|
||||
$(MAGIC_FRAGMENT_DIR)/sylk \
|
||||
$(MAGIC_FRAGMENT_DIR)/symbos \
|
||||
|
11
external/bsd/file/dist/magic/Makefile.in
vendored
11
external/bsd/file/dist/magic/Makefile.in
vendored
@ -274,7 +274,7 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
#
|
||||
# $File: Makefile.am,v 1.157 2020/05/21 16:22:47 christos Exp $
|
||||
# $File: Makefile.am,v 1.166 2021/03/14 16:24:18 christos Exp $
|
||||
#
|
||||
MAGIC_FRAGMENT_BASE = magdir
|
||||
MAGIC_DIR = $(top_srcdir)/magic
|
||||
@ -286,6 +286,7 @@ $(MAGIC_DIR)/Localstuff \
|
||||
$(MAGIC_FRAGMENT_DIR)/acorn \
|
||||
$(MAGIC_FRAGMENT_DIR)/adi \
|
||||
$(MAGIC_FRAGMENT_DIR)/adventure \
|
||||
$(MAGIC_FRAGMENT_DIR)/aes \
|
||||
$(MAGIC_FRAGMENT_DIR)/algol68 \
|
||||
$(MAGIC_FRAGMENT_DIR)/allegro \
|
||||
$(MAGIC_FRAGMENT_DIR)/alliant \
|
||||
@ -306,6 +307,7 @@ $(MAGIC_FRAGMENT_DIR)/assembler \
|
||||
$(MAGIC_FRAGMENT_DIR)/asterix \
|
||||
$(MAGIC_FRAGMENT_DIR)/att3b \
|
||||
$(MAGIC_FRAGMENT_DIR)/audio \
|
||||
$(MAGIC_FRAGMENT_DIR)/avm \
|
||||
$(MAGIC_FRAGMENT_DIR)/basis \
|
||||
$(MAGIC_FRAGMENT_DIR)/beetle \
|
||||
$(MAGIC_FRAGMENT_DIR)/ber \
|
||||
@ -317,6 +319,7 @@ $(MAGIC_FRAGMENT_DIR)/blackberry \
|
||||
$(MAGIC_FRAGMENT_DIR)/blcr \
|
||||
$(MAGIC_FRAGMENT_DIR)/blender \
|
||||
$(MAGIC_FRAGMENT_DIR)/blit \
|
||||
$(MAGIC_FRAGMENT_DIR)/bm \
|
||||
$(MAGIC_FRAGMENT_DIR)/bout \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsdi \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsi \
|
||||
@ -342,6 +345,7 @@ $(MAGIC_FRAGMENT_DIR)/console \
|
||||
$(MAGIC_FRAGMENT_DIR)/convex \
|
||||
$(MAGIC_FRAGMENT_DIR)/coverage \
|
||||
$(MAGIC_FRAGMENT_DIR)/cracklib \
|
||||
$(MAGIC_FRAGMENT_DIR)/crypto \
|
||||
$(MAGIC_FRAGMENT_DIR)/ctags \
|
||||
$(MAGIC_FRAGMENT_DIR)/ctf \
|
||||
$(MAGIC_FRAGMENT_DIR)/cubemap \
|
||||
@ -421,12 +425,14 @@ $(MAGIC_FRAGMENT_DIR)/keepass \
|
||||
$(MAGIC_FRAGMENT_DIR)/kerberos \
|
||||
$(MAGIC_FRAGMENT_DIR)/kicad \
|
||||
$(MAGIC_FRAGMENT_DIR)/kml \
|
||||
$(MAGIC_FRAGMENT_DIR)/lammps \
|
||||
$(MAGIC_FRAGMENT_DIR)/lecter \
|
||||
$(MAGIC_FRAGMENT_DIR)/lex \
|
||||
$(MAGIC_FRAGMENT_DIR)/lif \
|
||||
$(MAGIC_FRAGMENT_DIR)/linux \
|
||||
$(MAGIC_FRAGMENT_DIR)/lisp \
|
||||
$(MAGIC_FRAGMENT_DIR)/llvm \
|
||||
$(MAGIC_FRAGMENT_DIR)/locoscript \
|
||||
$(MAGIC_FRAGMENT_DIR)/lua \
|
||||
$(MAGIC_FRAGMENT_DIR)/luks \
|
||||
$(MAGIC_FRAGMENT_DIR)/m4 \
|
||||
@ -494,11 +500,13 @@ $(MAGIC_FRAGMENT_DIR)/pbf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pbm \
|
||||
$(MAGIC_FRAGMENT_DIR)/pc88 \
|
||||
$(MAGIC_FRAGMENT_DIR)/pc98 \
|
||||
$(MAGIC_FRAGMENT_DIR)/pcjr \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdp \
|
||||
$(MAGIC_FRAGMENT_DIR)/perl \
|
||||
$(MAGIC_FRAGMENT_DIR)/pgf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pgp \
|
||||
$(MAGIC_FRAGMENT_DIR)/pgp-binary-keys \
|
||||
$(MAGIC_FRAGMENT_DIR)/pkgadd \
|
||||
$(MAGIC_FRAGMENT_DIR)/plan9 \
|
||||
$(MAGIC_FRAGMENT_DIR)/plus5 \
|
||||
@ -545,6 +553,7 @@ $(MAGIC_FRAGMENT_DIR)/spectrum \
|
||||
$(MAGIC_FRAGMENT_DIR)/sql \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssh \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssl \
|
||||
$(MAGIC_FRAGMENT_DIR)/statistics \
|
||||
$(MAGIC_FRAGMENT_DIR)/sun \
|
||||
$(MAGIC_FRAGMENT_DIR)/sylk \
|
||||
$(MAGIC_FRAGMENT_DIR)/symbos \
|
||||
|
104
external/bsd/file/dist/magic/magdir/archive
vendored
104
external/bsd/file/dist/magic/magdir/archive
vendored
@ -1,5 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: archive,v 1.138 2020/06/07 23:29:26 christos Exp $
|
||||
# $File: archive,v 1.146 2021/04/08 23:54:36 christos Exp $
|
||||
# archive: file(1) magic for archive formats (see also "msdos" for self-
|
||||
# extracting compressed archives)
|
||||
#
|
||||
@ -240,7 +240,7 @@
|
||||
!:ext deb/udeb/ipk
|
||||
# This should not happen
|
||||
>14 default x Unknown Debian package
|
||||
# NL terminated version; for most Debian cases this is 2.0 or 2.1 for splitted
|
||||
# NL terminated version; for most Debian cases this is 2.0 or 2.1 for split
|
||||
>68 string >\0 (format %s)
|
||||
#>68 string !2.0\n
|
||||
#>>68 string x (format %.3s)
|
||||
@ -261,7 +261,7 @@
|
||||
>>>>>>>&-1 ubyte !0x2f
|
||||
# display 4th character of file name extension like a of lzma
|
||||
>>>>>>>>&-1 ubyte x \b%c
|
||||
# splitted debian package case
|
||||
# split debian package case
|
||||
>68 string =2.1\n
|
||||
# dpkg-1.18.25/dpkg-split/info.c
|
||||
# NL terminated ASCII package name like ckermit
|
||||
@ -453,30 +453,45 @@
|
||||
# URL: https://wiki.68kmla.org/DiskCopy_4.2_format_specification
|
||||
# reference: http://nulib.com/library/FTN.e00005.htm
|
||||
0x52 ubeshort 0x0100
|
||||
# test for disk size equal or above 400k
|
||||
>0x40 ubelong >409599 Apple DiskCopy 4.2 image
|
||||
# test for disk image size equal or above 400k
|
||||
>0x40 ubelong >409599
|
||||
# test also for disk image size equal or below 1440k to skip
|
||||
# windows7en.mbr UNICODE.DAT
|
||||
>>0x40 ubelong <1474561
|
||||
# To skip Flags$StringJoiner.class with size 00106A61h test also for only 4 disk image sizes
|
||||
# 00064000 for 400k GCR disks
|
||||
# 000c8000 for 800k GCR disks
|
||||
# 000b4000 for 720k MFM disks
|
||||
# 00168000 for 1440k MFM disks
|
||||
>>>0x40 ubelong&0xffE03fFF 0
|
||||
>>>>0 use dc42-floppy
|
||||
# display information of Apple DiskCopy 4.2 floppy image
|
||||
0 name dc42-floppy
|
||||
# image pascal name padded with NULs like Microsoft Mail
|
||||
>00 pstring/B x Apple DiskCopy 4.2 image %s
|
||||
#!:mime application/octet-stream
|
||||
!:mime application/x-dc42-floppy-image
|
||||
!:apple dCpydImg
|
||||
!:ext image/dc42
|
||||
# image pascal name padded with NULs like Microsoft Mail
|
||||
>>00 pstring/B x %s
|
||||
# data size in bytes like 409600
|
||||
>>0x40 ubelong x \b, %u bytes
|
||||
>0x40 ubelong x \b, %u bytes
|
||||
# for debugging purpose size in hexadecimal
|
||||
#>0x40 ubelong x (0x%8.8x)
|
||||
# tag size in bytes
|
||||
>>0x44 ubelong >0 \b, 0x%x tag size
|
||||
>0x44 ubelong >0 \b, 0x%x tag size
|
||||
# data checksum
|
||||
#>>0x48 ubelong x \b, 0x%x checksum
|
||||
#>0x48 ubelong x \b, 0x%x checksum
|
||||
# tag checksum
|
||||
#>>0x4c ubelong x \b, 0x%x tag checksum
|
||||
#>0x4c ubelong x \b, 0x%x tag checksum
|
||||
# disk encoding
|
||||
>>0x50 ubyte 0 \b, GCR CLV ssdd (400k)
|
||||
>>0x50 ubyte 1 \b, GCR CLV dsdd (800k)
|
||||
>>0x50 ubyte 2 \b, MFM CAV dsdd (720k)
|
||||
>>0x50 ubyte 3 \b, MFM CAV dshd (1440k)
|
||||
>>0x50 ubyte >3 \b, 0x%x encoding
|
||||
>0x50 ubyte 0 \b, GCR CLV ssdd (400k)
|
||||
>0x50 ubyte 1 \b, GCR CLV dsdd (800k)
|
||||
>0x50 ubyte 2 \b, MFM CAV dsdd (720k)
|
||||
>0x50 ubyte 3 \b, MFM CAV dshd (1440k)
|
||||
>0x50 ubyte >3 \b, 0x%x encoding
|
||||
# format byte
|
||||
>>0x51 ubyte x \b, 0x%x format
|
||||
#>>0x54 ubequad x \b, data 0x%16.16llx
|
||||
>0x51 ubyte x \b, 0x%x format
|
||||
#>0x54 ubequad x \b, data 0x%16.16llx
|
||||
# ESP, could this conflict with Easy Software Products' (e.g.ESP ghostscript) documentation?
|
||||
0 string ESP ESP archive data
|
||||
# ZPack
|
||||
@ -603,6 +618,21 @@
|
||||
!:ext ??$
|
||||
>>8 ulelong >0 \b, original size: %u bytes
|
||||
|
||||
# Summary: FTCOMP compressed archive
|
||||
# From: Joerg Jenderek
|
||||
# URL: http://fileformats.archiveteam.org/wiki/FTCOMP
|
||||
# Reference: http://mark0.net/download/triddefs_xml.7z/defs/a/ark-ftcomp.trid.xml
|
||||
# Note: called by TrID "FTCOMP compressed archive"
|
||||
# extracted by `unpack seahelp.hl_`
|
||||
24 string/b FTCOMP FTCOMP compressed archive
|
||||
#!:mime application/octet-stream
|
||||
!:mime application/x-compress-ftcomp
|
||||
!:ext ??_/??@/dll/drv/pk2/
|
||||
# probably A596FDFF magic at the beginning
|
||||
>0 ubelong !0xA596FDFF \b, at beginning 0x%x
|
||||
# probably orginal file name with directory like: \OS2\unpack.exe \SYSTEM\8514.DRV MAHJONGG.EXE
|
||||
>41 string x "%s"
|
||||
|
||||
# MP3 (archiver, not lossy audio compression)
|
||||
0 string MP3\x1a MP3-Archiver archive data
|
||||
# ZET
|
||||
@ -923,7 +953,7 @@
|
||||
>>>>>>3 regex \^lh[456] LHa (2.x) archive data
|
||||
>>>>>>>2 string -lh5 \b
|
||||
# https://en.wikipedia.org/wiki/BIOS
|
||||
# Some mainboard BIOS like Award use LHa compression. So archives with unusal extension are found like
|
||||
# Some mainboard BIOS like Award use LHa compression. So archives with unusual extension are found like
|
||||
# bios.rom , kd7_v14.bin, 1010.004, ...
|
||||
!:ext lha/lzh/rom/bin
|
||||
# missing -lh?- variants (Joe Jared)
|
||||
@ -1331,6 +1361,8 @@
|
||||
>>>>4 beshort x \b, at least
|
||||
>>>>4 use zipversion
|
||||
>>>>4 beshort x to extract
|
||||
>>>>8 beshort x \b, compression method=
|
||||
>>>>8 use zipcompression
|
||||
>>>>0x161 string WINZIP \b, WinZIP self-extracting
|
||||
|
||||
# StarView Metafile
|
||||
@ -1472,8 +1504,17 @@
|
||||
>>0x2A string >\0 : %s
|
||||
|
||||
# DR-DOS 7.03 Packed File *.??_
|
||||
0 string Packed\ File\ Personal NetWare Packed File
|
||||
>12 string x \b, was "%.12s"
|
||||
# Reference: http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm
|
||||
# Note: unpacked by PNUNPACK.EXE
|
||||
0 string Packed\ File\
|
||||
# by looking for Control-Z skip ASCII text starting with Packed File
|
||||
>0x18 ubyte 0x1a Personal NetWare Packed File
|
||||
!:mime application/x-novell-compress
|
||||
!:ext ??_
|
||||
>>12 string x \b, was "%.12s"
|
||||
# 1 or 2
|
||||
#>>0x19 ubyte x \b, at 0x19 %u
|
||||
>>0x1b ulelong x with %u bytes
|
||||
|
||||
# EET archive
|
||||
# From: Tilman Sauerbeck <tilman@code-monkey.de>
|
||||
@ -1719,3 +1760,24 @@
|
||||
# path[CXBTFFile[MaximumPathLength=256]
|
||||
>>9 string x \b, 1st %s
|
||||
|
||||
# ALZIP archive
|
||||
# by Hyungjun Park <hyungjun.park@worksmobile.com>, Hajin Jang <hajin_jang@worksmobile.com>
|
||||
# http://kippler.com/win/unalz/
|
||||
# https://salsa.debian.org/l10n-korean-team/unalz
|
||||
0 string ALZ\001 ALZ archive data
|
||||
!:ext alz
|
||||
|
||||
# https://cf-aldn.altools.co.kr/setup/EGG_Specification.zip
|
||||
0 string EGGA EGG archive data,
|
||||
!:ext egg
|
||||
>5 byte x version %u
|
||||
>4 byte x \b.%u
|
||||
>>0x0E ulelong =0x08E28222
|
||||
>>0x0E ulelong =0x24F5A262 \b, split
|
||||
>>0x0E ulelong =0x24E5A060 \b, solid
|
||||
>>0x0E default x \b, unknown
|
||||
|
||||
# PAQ9A archive
|
||||
# URL: http://mattmahoney.net/dc/#paq9a
|
||||
# Note: Line 1186 of paq9a.cpp gives the magic bytes
|
||||
0 string pQ9\001 PAQ9A archive
|
||||
|
9
external/bsd/file/dist/magic/magdir/cad
vendored
9
external/bsd/file/dist/magic/magdir/cad
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: cad,v 1.25 2021/02/23 00:51:10 christos Exp $
|
||||
# $File: cad,v 1.26 2021/04/08 22:50:22 christos Exp $
|
||||
# autocad: file(1) magic for cad files
|
||||
#
|
||||
|
||||
@ -330,3 +330,10 @@
|
||||
|
||||
4 regex/b P[0-9][0-9]\\.[0-9][0-9][0-9][0-9]\\.[0-9][0-9][0-9][0-9]\\.[0-9] NAXOS CAD System file from version %s
|
||||
!:strength +40
|
||||
|
||||
# glTF (GL Transmission Format). The specification is at
|
||||
# https://github.com/KhronosGroup/glTF
|
||||
0 string glTF glTF binary asset
|
||||
>4 lelong x \b, version %d
|
||||
>8 lelong x \b, length %d bytes.
|
||||
!:mime model/gltf-binary
|
||||
|
7
external/bsd/file/dist/magic/magdir/coff
vendored
7
external/bsd/file/dist/magic/magdir/coff
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: coff,v 1.4 2021/02/10 00:37:02 christos Exp $
|
||||
# $File: coff,v 1.5 2021/04/04 18:24:34 christos Exp $
|
||||
# coff: file(1) magic for Common Object Files not specific to known cpu types or manufactures
|
||||
#
|
||||
# COFF
|
||||
@ -34,6 +34,11 @@
|
||||
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx
|
||||
>>>>0 uleshort 0x0200 Intel ia64
|
||||
>>>>0 uleshort 0x8664 Intel amd64
|
||||
# ARM COFF (./arm)
|
||||
>>>>0 uleshort 0xaa64 Aarch64
|
||||
>>>>0 uleshort 0x01c0 ARM
|
||||
>>>>0 uleshort 0x01c2 ARM Thumb
|
||||
>>>>0 uleshort 0x01c4 ARMv7 Thumb
|
||||
# TODO for other COFFs
|
||||
#>>>>0 uleshort 0xABCD COFF_TEMPLATE
|
||||
>>>>0 default x
|
||||
|
6
external/bsd/file/dist/magic/magdir/commands
vendored
6
external/bsd/file/dist/magic/magdir/commands
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: commands,v 1.63 2020/06/06 15:36:30 christos Exp $
|
||||
# $File: commands,v 1.64 2021/04/06 15:43:11 christos Exp $
|
||||
# commands: file(1) magic for various shells and interpreters
|
||||
#
|
||||
#0 string/w : shell archive or script for antique kernel text
|
||||
@ -38,6 +38,10 @@
|
||||
0 search/1 #!/usr/bin/env\ zsh Paul Falstad's zsh script text executable
|
||||
!:mime text/x-shellscript
|
||||
|
||||
0 string/wt #!\ /bin/ash Neil Brown's ash script text executable
|
||||
!:mime text/x-shellscript
|
||||
0 string/wt #!\ /usr/bin/ash Neil Brown's ash script text executable
|
||||
!:mime text/x-shellscript
|
||||
0 string/wt #!\ /usr/local/bin/ash Neil Brown's ash script text executable
|
||||
!:mime text/x-shellscript
|
||||
0 string/wt #!\ /usr/local/bin/ae Neil Brown's ae script text executable
|
||||
|
15
external/bsd/file/dist/magic/magdir/diff
vendored
15
external/bsd/file/dist/magic/magdir/diff
vendored
@ -1,11 +1,12 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: diff,v 1.16 2017/03/17 22:20:22 christos Exp $
|
||||
# $File: diff,v 1.17 2020/08/22 18:16:58 christos Exp $
|
||||
# diff: file(1) magic for diff(1) output
|
||||
#
|
||||
0 search/1 diff\040 diff output text
|
||||
!:mime text/x-diff
|
||||
0 search/1 ***\040 diff output text
|
||||
0 search/1 ***\040
|
||||
>&0 search/1024 \n---\040 context diff output text
|
||||
!:mime text/x-diff
|
||||
0 search/1 Only\040in\040 diff output text
|
||||
!:mime text/x-diff
|
||||
@ -16,15 +17,15 @@
|
||||
!:mime text/x-diff
|
||||
|
||||
# bsdiff: file(1) magic for bsdiff(1) output
|
||||
0 string/b BSDIFF40 bsdiff(1) patch file
|
||||
0 string/b BSDIFF40 bsdiff(1) patch file
|
||||
|
||||
|
||||
# unified diff
|
||||
0 search/4096 ---\040
|
||||
>&0 search/1024 \n
|
||||
>>&0 search/1 +++\040
|
||||
>>>&0 search/1024 \n
|
||||
>>>>&0 search/1 @@ unified diff output text
|
||||
>&0 search/1024 \n
|
||||
>>&0 search/1 +++\040
|
||||
>>>&0 search/1024 \n
|
||||
>>>>&0 search/1 @@ unified diff output text
|
||||
!:mime text/x-diff
|
||||
!:strength + 90
|
||||
|
||||
|
46
external/bsd/file/dist/magic/magdir/elf
vendored
46
external/bsd/file/dist/magic/magdir/elf
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: elf,v 1.80 2020/02/12 22:17:33 christos Exp $
|
||||
# $File: elf,v 1.85 2021/03/27 20:18:38 christos Exp $
|
||||
# elf: file(1) magic for ELF executables
|
||||
#
|
||||
# We have to check the byte order flag to see what byte order all the
|
||||
@ -43,6 +43,14 @@
|
||||
>2 leshort 0x0214 2.0
|
||||
>0 leshort &0x0008 (LP64)
|
||||
|
||||
0 name elf-riscv
|
||||
>0 lelong&0x00000001 0x00000001 RVC,
|
||||
>0 lelong&0x00000008 0x00000008 RVE,
|
||||
>0 lelong&0x00000006 0x00000000 soft-float ABI,
|
||||
>0 lelong&0x00000006 0x00000002 single-float ABI,
|
||||
>0 lelong&0x00000006 0x00000004 double-float ABI,
|
||||
>0 lelong&0x00000006 0x00000006 quad-float ABI,
|
||||
|
||||
0 name elf-le
|
||||
>16 leshort 0 no file type,
|
||||
!:mime application/octet-stream
|
||||
@ -62,7 +70,12 @@
|
||||
# Core file detection is not reliable.
|
||||
#>>>(0x38+0xcc) string >\0 of '%s'
|
||||
#>>>(0x38+0x10) lelong >0 (signal %d),
|
||||
>16 leshort &0xff00 processor-specific,
|
||||
>16 leshort &0xff00
|
||||
>>18 leshort !8 processor-specific,
|
||||
>>18 leshort 8
|
||||
>>>16 leshort 0xFF80 PlayStation 2 IOP module,
|
||||
!:mime application/x-sharedlib
|
||||
>>>16 leshort !0xFF80 processor-specific,
|
||||
>18 clear x
|
||||
>18 leshort 0 no machine,
|
||||
>18 leshort 1 AT&T WE32100,
|
||||
@ -111,6 +124,9 @@
|
||||
>18 leshort 19 Intel 80960,
|
||||
>18 leshort 20 PowerPC or cisco 4500,
|
||||
>18 leshort 21 64-bit PowerPC or cisco 7500,
|
||||
>>48 lelong 0 Unspecified or Power ELF V1 ABI,
|
||||
>>48 lelong 1 Power ELF V1 ABI,
|
||||
>>48 lelong 2 OpenPOWER ELF V2 ABI,
|
||||
>18 leshort 22 IBM S/390,
|
||||
>18 leshort 23 Cell SPU,
|
||||
>18 leshort 24 cisco SVIP,
|
||||
@ -179,7 +195,7 @@
|
||||
>18 leshort 90 Matsushita MN10200,
|
||||
>18 leshort 91 picoJava,
|
||||
>18 leshort 92 OpenRISC,
|
||||
>18 leshort 93 ARC Cores Tangent-A5,
|
||||
>18 leshort 93 Synopsys ARCompact ARC700 cores,
|
||||
>18 leshort 94 Tensilica Xtensa,
|
||||
>18 leshort 95 Alphamosaic VideoCore,
|
||||
>18 leshort 96 Thompson Multimedia,
|
||||
@ -218,6 +234,7 @@
|
||||
>18 leshort 140 TI TMS320C6000 DSP family,
|
||||
>18 leshort 141 TI TMS320C2000 DSP family,
|
||||
>18 leshort 142 TI TMS320C55x DSP family,
|
||||
>18 leshort 144 TI Programmable Realtime Unit
|
||||
>18 leshort 160 STMicroelectronics 64bit VLIW DSP,
|
||||
>18 leshort 161 Cypress M8C,
|
||||
>18 leshort 162 Renesas R32C series,
|
||||
@ -248,6 +265,7 @@
|
||||
>18 leshort 189 Xilinx MicroBlaze 32-bit RISC,
|
||||
>18 leshort 190 NVIDIA CUDA architecture,
|
||||
>18 leshort 191 Tilera TILE-Gx,
|
||||
>18 leshort 195 Synopsys ARCv2/HS3x/HS4x cores,
|
||||
>18 leshort 197 Renesas RL78 family,
|
||||
>18 leshort 199 Renesas 78K0R,
|
||||
>18 leshort 200 Freescale 56800EX,
|
||||
@ -265,8 +283,28 @@
|
||||
>18 leshort 217 iCelero CoolEngine,
|
||||
>18 leshort 218 Nanoradio Optimized RISC,
|
||||
>18 leshort 243 UCB RISC-V,
|
||||
# only for 32-bit
|
||||
>>4 byte 1
|
||||
>>>36 use elf-riscv
|
||||
# only for 64-bit
|
||||
>>4 byte 2
|
||||
>>>48 use elf-riscv
|
||||
>18 leshort 244 Lanai 32-bit processor,
|
||||
>18 leshort 245 CEVA Processor Architecture Family,
|
||||
>18 leshort 246 CEVA X2 Processor Family,
|
||||
>18 leshort 247 eBPF,
|
||||
>18 leshort 251 NEC VE,
|
||||
>18 leshort 248 Graphcore Intelligent Processing Unit,
|
||||
>18 leshort 249 Imagination Technologies,
|
||||
>18 leshort 250 Netronome Flow Processor,
|
||||
>18 leshort 251 NEC Vector Engine,
|
||||
>18 leshort 252 C-SKY processor family,
|
||||
>18 leshort 253 Synopsys ARCv3 64-bit ISA/HS6x cores,
|
||||
>18 leshort 254 MOS Technology MCS 6502 processor,
|
||||
>18 leshort 255 Synopsys ARCv3 32-bit,
|
||||
>18 leshort 256 Kalray VLIW core of the MPPA family,
|
||||
>18 leshort 257 WDC 65816/65C816,
|
||||
>18 leshort 258 Loongson Loongarch,
|
||||
>18 leshort 259 ChipON KungFu32,
|
||||
>18 leshort 0x1057 AVR (unofficial),
|
||||
>18 leshort 0x1059 MSP430 (unofficial),
|
||||
>18 leshort 0x1223 Adapteva Epiphany (unofficial),
|
||||
|
108
external/bsd/file/dist/magic/magdir/filesystems
vendored
108
external/bsd/file/dist/magic/magdir/filesystems
vendored
@ -1,5 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: filesystems,v 1.133 2020/05/17 19:32:00 christos Exp $
|
||||
# $File: filesystems,v 1.141 2021/04/04 17:46:17 christos Exp $
|
||||
# filesystems: file(1) magic for different filesystems
|
||||
#
|
||||
0 name partid
|
||||
@ -261,6 +261,18 @@
|
||||
# for sector sizes with 512 or more Bytes
|
||||
>0x1FE leshort 0xAA55 DOS/MBR boot sector
|
||||
|
||||
# ExFAT
|
||||
3 string/w =EXFAT
|
||||
>0x1FE leshort 0xAA55
|
||||
>>0x6E ubyte 1
|
||||
>>>0x6F ubyte 0x80
|
||||
>>>0 ubyte 0xEB DOS/MBR boot sector,
|
||||
>>>0x69 ubyte x ExFAT Filesystem version %d.
|
||||
>>>0x68 ubyte x \b%d
|
||||
>>>0x6d ubyte x \b, (1<<%d) sectors per cluster
|
||||
>>>0x48 ulequad x \b, sectors %lld
|
||||
>>>0x64 ulelong x \b, serial number 0x%x
|
||||
|
||||
# keep old DOS/MBR boot sector as dummy for mbr and bootloader displaying
|
||||
# only for sector sizes with 512 or more Bytes
|
||||
0x1FE leshort 0xAA55 DOS/MBR boot sector
|
||||
@ -491,7 +503,7 @@
|
||||
# updated by Joerg Jenderek at Oct 2008
|
||||
# variables according to grub-0.97/stage1/stage1.S or
|
||||
# https://www.gnu.org/software/grub/manual/grub.html#Embedded-data
|
||||
# usual values are marked with comments to get only informations of strange GRUB loaders
|
||||
# usual values are marked with comments to get only information of strange GRUB loaders
|
||||
>342 search/60 \0Geom\0
|
||||
#>0 ulelong x %x=0x009048EB , 0x2a9048EB 0
|
||||
>>0x41 ubyte <2
|
||||
@ -533,7 +545,7 @@
|
||||
# mbr partition table entries updated by Joerg Jenderek at Sep 2013
|
||||
# skip Norton Utilities disc image data
|
||||
>3 string !IHISK
|
||||
# skip Linux style boot sector starting with assember instructions mov 0x7c0,ax;
|
||||
# skip Linux style boot sector starting with assembler instructions mov 0x7c0,ax;
|
||||
>>0 belong !0xb8c0078e
|
||||
# not Linux kernel
|
||||
>>>514 string !HdrS
|
||||
@ -548,7 +560,7 @@
|
||||
>>>>>0 ubelong&0xFD000000 !0xE9000000
|
||||
# skip FSInfosector
|
||||
>>>>>>0 string !RRaA
|
||||
# skip 3rd sector of MS x86 bootloader with assember instructions cli;MOVZX EAX,BYTE PTR [BP+10];MOV ECX,
|
||||
# skip 3rd sector of MS x86 bootloader with assembler instructions cli;MOVZX EAX,BYTE PTR [BP+10];MOV ECX,
|
||||
# https://thestarman.pcministry.com/asm/mbr/MSWIN41.htm
|
||||
>>>>>>>0 ubequad !0xfa660fb64610668b
|
||||
# skip 13rd sector of MS x86 bootloader
|
||||
@ -1296,7 +1308,7 @@
|
||||
# In the second sector (+0x200) are variables according to grub-0.97/stage2/asm.S or
|
||||
# grub-1.94/kern/i386/pc/startup.S
|
||||
# https://www.gnu.org/software/grub/manual/grub.html#Embedded-data
|
||||
# usual values are marked with comments to get only informations of strange GRUB loaders
|
||||
# usual values are marked with comments to get only information of strange GRUB loaders
|
||||
0x200 uleshort 0x70EA
|
||||
# found only version 3.{1,2}
|
||||
>0x206 ubeshort >0x0300
|
||||
@ -1358,7 +1370,7 @@
|
||||
0 ulelong&0x804000E9 0x000000E9
|
||||
!:strength +60
|
||||
# mtools-3.9.8/msdos.h
|
||||
# usual values are marked with comments to get only informations of strange FAT systems
|
||||
# usual values are marked with comments to get only information of strange FAT systems
|
||||
# valid sectorsize must be a power of 2 from 32 to 32768
|
||||
>11 uleshort&0x001f 0
|
||||
>>11 uleshort <32769
|
||||
@ -1421,7 +1433,7 @@
|
||||
# in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too
|
||||
>>>>>>>>37 ubyte >0 \b, reserved 0x%x
|
||||
#>>>>>>>>37 ubyte =0 \b, reserved 0x%x
|
||||
# extended boot signatur value is 0x80 for NTFS, 0x28 or 0x29 for others
|
||||
# extended boot signature value is 0x80 for NTFS, 0x28 or 0x29 for others
|
||||
>>>>>>>>38 ubyte !0x29 \b, dos < 4.0 BootSector (0x%x)
|
||||
>>>>>>>>38 ubyte&0xFE =0x28
|
||||
>>>>>>>>>39 ulelong x \b, serial number 0x%x
|
||||
@ -1727,12 +1739,12 @@
|
||||
>>>0x464 lelong >0x0000007 ext4 filesystem data
|
||||
# else large INCOMPAT?
|
||||
>>0x460 lelong >0x000003f ext4 filesystem data
|
||||
>0x468 belong x \b, UUID=%08x
|
||||
>0x46c beshort x \b-%04x
|
||||
>0x46e beshort x \b-%04x
|
||||
>0x470 beshort x \b-%04x
|
||||
>0x472 belong x \b-%08x
|
||||
>0x476 beshort x \b%04x
|
||||
>0x468 ubelong x \b, UUID=%08x
|
||||
>0x46c ubeshort x \b-%04x
|
||||
>0x46e ubeshort x \b-%04x
|
||||
>0x470 ubeshort x \b-%04x
|
||||
>0x472 ubelong x \b-%08x
|
||||
>0x476 ubeshort x \b%04x
|
||||
>0x478 string >0 \b, volume name "%s"
|
||||
# General flags for any ext* fs
|
||||
>0x460 lelong &0x0000004 (needs journal recovery)
|
||||
@ -1755,12 +1767,12 @@
|
||||
|
||||
# f2fs filesystem - Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
|
||||
0x400 lelong 0xF2F52010 F2FS filesystem
|
||||
>0x46c belong x \b, UUID=%08x
|
||||
>0x470 beshort x \b-%04x
|
||||
>0x472 beshort x \b-%04x
|
||||
>0x474 beshort x \b-%04x
|
||||
>0x476 belong x \b-%08x
|
||||
>0x47a beshort x \b%04x
|
||||
>0x46c ubelong x \b, UUID=%08x
|
||||
>0x470 ubeshort x \b-%04x
|
||||
>0x472 ubeshort x \b-%04x
|
||||
>0x474 ubeshort x \b-%04x
|
||||
>0x476 ubelong x \b-%08x
|
||||
>0x47a ubeshort x \b%04x
|
||||
>0x147c lestring16 x \b, volume name "%s"
|
||||
|
||||
# Minix filesystems - Juan Cespedes <cespedes@debian.org>
|
||||
@ -1980,11 +1992,14 @@
|
||||
# The next line is not necessary because the MBR staff is done looking for boot signature
|
||||
>0x1FE leshort 0xAA55 (DOS/MBR boot sector)
|
||||
# "application id" which appears to be used as a volume label
|
||||
>32808 string/T >\0 '%s'
|
||||
>32808 string/T >\0 '%.32s'
|
||||
>34816 string \000CD001\001EL\ TORITO\ SPECIFICATION (bootable)
|
||||
37633 string CD001 ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
|
||||
!:mime application/x-iso9660-image
|
||||
32777 string CDROM High Sierra CD-ROM filesystem data
|
||||
# "application id" which appears to be used as a volume label
|
||||
>32816 string/T >\0 '%.32s'
|
||||
|
||||
|
||||
# CDROM Filesystems
|
||||
# https://en.wikipedia.org/wiki/ISO_9660
|
||||
@ -2281,20 +2296,20 @@
|
||||
>>0x10060 string >\0 lockproto %s)
|
||||
|
||||
# Russell Coker <russell@coker.com.au>
|
||||
0x10040 string _BHRfS_M BTRFS Filesystem
|
||||
>0x1012b string >\0 label "%s",
|
||||
>0x10090 lelong x sectorsize %d,
|
||||
>0x10094 lelong x nodesize %d,
|
||||
>0x10098 lelong x leafsize %d,
|
||||
>0x10020 belong x UUID=%08x-
|
||||
>0x10024 beshort x \b%04x-
|
||||
>0x10026 beshort x \b%04x-
|
||||
>0x10028 beshort x \b%04x-
|
||||
>0x1002a beshort x \b%04x
|
||||
>0x1002c belong x \b%08x,
|
||||
>0x10078 lequad x %lld/
|
||||
>0x10070 lequad x \b%lld bytes used,
|
||||
>0x10088 lequad x %lld devices
|
||||
0x10040 string _BHRfS_M BTRFS Filesystem
|
||||
>0x1012b string >\0 label "%s",
|
||||
>0x10090 lelong x sectorsize %d,
|
||||
>0x10094 lelong x nodesize %d,
|
||||
>0x10098 lelong x leafsize %d,
|
||||
>0x10020 ubelong x UUID=%08x-
|
||||
>0x10024 ubeshort x \b%04x-
|
||||
>0x10026 ubeshort x \b%04x-
|
||||
>0x10028 ubeshort x \b%04x-
|
||||
>0x1002a ubeshort x \b%04x
|
||||
>0x1002c ubelong x \b%08x,
|
||||
>0x10078 lequad x %lld/
|
||||
>0x10070 lequad x \b%lld bytes used,
|
||||
>0x10088 lequad x %lld devices
|
||||
|
||||
# dvdisaster's .ecc
|
||||
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
@ -2433,3 +2448,28 @@
|
||||
>0x400 pstring x serial: %s
|
||||
#>0x500 pstring x unknown: %s
|
||||
!:ext imgc
|
||||
|
||||
# http://martin.hinner.info/fs/bfs/bfs-structure.html
|
||||
0 lelong 0x1BADFACE SCO UnixWare BFS filesystem
|
||||
|
||||
# https://arstechnica.com/information-technology/2018/07/the-beos-filesystem/
|
||||
32 lelong 0x42465331 BE/OS BFS1 filesystem
|
||||
>36 lelong x \b, byte order %d
|
||||
>40 lelong x \b, block size %d
|
||||
>44 lelong x \b, block shift %d
|
||||
>48 lequad x \b, total blocks %lld
|
||||
>56 lequad x \b, used blocks %lld
|
||||
|
||||
|
||||
0 name next
|
||||
>0 lelong x \b, size %d
|
||||
>4 string x \b, label %s
|
||||
|
||||
# https://opensource.apple.com/source/IOStorageFamily/IOStorageFamily-44.3\
|
||||
# /IONeXTPartitionScheme.h
|
||||
0 string NeXT NeXT version 1 disklabel
|
||||
>12 use next
|
||||
0 string dlV1 NeXT version 2 disklabel
|
||||
>12 use next
|
||||
0 string dlV2 NeXT version 3 disklabel
|
||||
>12 use next
|
||||
|
200
external/bsd/file/dist/magic/magdir/games
vendored
200
external/bsd/file/dist/magic/magdir/games
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: games,v 1.22 2021/02/23 00:51:10 christos Exp $
|
||||
# $File: games,v 1.23 2021/04/06 21:58:26 christos Exp $
|
||||
# games: file(1) for games
|
||||
|
||||
# Fabio Bonelli <fabiobonelli@libero.it>
|
||||
@ -320,3 +320,201 @@
|
||||
!:mime application/syzygy
|
||||
0 string q\350#] Syzygy WDL tablebase
|
||||
!:mime application/syzygy
|
||||
|
||||
##############################################################################
|
||||
# Grand Theft Auto (GTA) file formats.
|
||||
#
|
||||
# Summary:
|
||||
# Includes GTA-specific formats used in all games from 1997 to present. Games
|
||||
# and formats were created by Rockstar North, formerly DMA Design. Magic tests
|
||||
# were written based on a combination of official and community documentation.
|
||||
#
|
||||
# Created by: Oliver Galvin <odg@riseup.net>
|
||||
#
|
||||
# References:
|
||||
# * Classic GTA documentation and research:
|
||||
# <https://gitlab.com/classic-gta/gta-data>
|
||||
# * Official RenderWare documentation available from EA:
|
||||
# <https://github.com/electronicarts/RenderWare3Docs>
|
||||
# * Lots of community research in the GTAMods wiki:
|
||||
# <https://gtamods.com/wiki>
|
||||
|
||||
# GTA 2D-Era data - 'Classic' top down games (1/L/2)
|
||||
|
||||
## GTA text
|
||||
|
||||
0 string \xbf\xf8\xbd\x49\x62\xbe GTA1 in-game text (FXT),
|
||||
0 string GBL GTA2 in-game text (GXT),
|
||||
>3 string E English,
|
||||
>>4 uleshort x version %d
|
||||
>3 string F French,
|
||||
>>4 uleshort x version %d
|
||||
>3 string G German,
|
||||
>>4 uleshort x version %d
|
||||
>3 string I Italian,
|
||||
>>4 uleshort x version %d
|
||||
>3 string S Spanish,
|
||||
>>4 uleshort x version %d
|
||||
>3 string J Japanese,
|
||||
>>4 uleshort x version %d
|
||||
|
||||
## GTA maps
|
||||
|
||||
0 ulelong 331 GTA1 map layout (CMP),
|
||||
>4 byte 1 Level 1
|
||||
>4 byte 2 Level 2
|
||||
>4 byte 3 Level 3
|
||||
0 string GBMP GTA2/GBH map layout (GMP),
|
||||
>4 uleshort x version %d
|
||||
0 string/t [MapFiles] GTA2 multiplayer map metadata (MMP)
|
||||
0 string/t MainOrBonus\ =\ MAIN GTA2 single player map listing (test1.seq)
|
||||
|
||||
## GTA 2D sprites and textures
|
||||
|
||||
0 ulelong 290 GTA1 style data (GRX), 8 bit editor graphics
|
||||
0 ulelong 325 GTA1 style data (GRY), 8 bit in-game graphics
|
||||
0 ulelong 336 GTA1 style data (G24), 24 bit in-game graphics
|
||||
0 string GBST GTA2/GBH style data (STY), in-game graphics,
|
||||
>4 uleshort x version %d
|
||||
|
||||
## GTA audio index
|
||||
|
||||
0 ulelong 0
|
||||
>4 ulelong <0x40000
|
||||
>>8 ulelong >4500
|
||||
>>>8 ulelong <45000 GTA audio index data (SDT)
|
||||
|
||||
## GTA scripts
|
||||
|
||||
0 ulelong 0x00080000
|
||||
>4 uleshort 0x0024 GTA2 binary main script (SCR)
|
||||
|
||||
0 uleshort 0x063c GTA2 binary mission script (SCR), Residential area (ste)
|
||||
0 uleshort 0x055b GTA2 binary mission script (SCR), Downtown area (wil)
|
||||
0 uleshort 0x0469 GTA2 binary mission script (SCR), Industrial area (bil)
|
||||
|
||||
0 string v9.6\0\0 GTA2 replay file (REP),
|
||||
>8 regex/30c [a-z0-9:\ ]+\0\0 created on %s
|
||||
|
||||
# GTA 3D-Era (III/VC/SA/LCS/VCS) - used by the RenderWare engine by Criterion Games
|
||||
|
||||
## GTA 3D models and textures - RenderWare binary streams
|
||||
|
||||
8 ulelong 0x00000310 RenderWare data, v3.1.0.0, used in GTA III on PS2,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x0401ffff RenderWare data, v3.1.0.1, used in GTA III on PC/PS2,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x0800ffff RenderWare data, v3.2.0.0, used in GTA III on PC,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x0c00ffff RenderWare data, v3.3.0.0,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x0c02ffff RenderWare data, v3.3.0.2, used in GTA III PC and GTA VC PS2,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x1000ffff RenderWare data, v3.4.0.0,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x1003ffff RenderWare data, v3.4.0.3, used in GTA VC PC,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x1005ffff RenderWare data, v3.4.0.5, used in GTA III/VC on Android,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x1400ffff RenderWare data, v3.5.0.0, used in GTA III/VC on Xbox,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
8 ulelong 0x1803ffff RenderWare data, v3.6.0.3, used in GTA SA,
|
||||
>0 ulelong 0x00000016 texture archive (TXD)
|
||||
>0 ulelong 0x00000010 3D models (DFF)
|
||||
|
||||
0 string COL RenderWare collision data (COL),
|
||||
>3 string L version 1, used in GTA III/VC/SA
|
||||
>3 string 2 version 2, used in GTA SA
|
||||
>3 string 3 version 3, used in GTA SA
|
||||
>3 string 4 version 4, used in GTA SA
|
||||
|
||||
## GTA items and animations
|
||||
|
||||
0 string/c #\ ipl\ generated\ from\ max\ file GTA Item Placement data (IPL), used in GTA III/VC
|
||||
0 string/b bnry GTA Item Placement data (IPL), used in GTA SA/IV,
|
||||
>4 ulelong x %d items
|
||||
|
||||
0 string ANP GTA animation data (IFP),
|
||||
>3 string K version 1, used in GTA III/VC
|
||||
>3 string 3 version 2, used in GTA SA
|
||||
|
||||
0 string GtaSA29 GTA Replay data (REP), used in GTA SA
|
||||
|
||||
## GTA text
|
||||
|
||||
0 string TKEY GTA in-game text (GXT), version 2, used in GTA III
|
||||
0 string TABL GTA in-game text (GXT), version 3, used in GTA VC/LS/VCS
|
||||
|
||||
## GTA scripts
|
||||
|
||||
0 string \x02\x00\x01 GTA script (SCM), used in GTA III/VC/SA
|
||||
|
||||
## GTA archives
|
||||
|
||||
0 string VER2 GTA archive (IMG), version 2, used in GTA SA,
|
||||
>4 ulelong x %d items
|
||||
|
||||
# GTA HD-Era (IV/V) - used by the Rockstar Advanced Game Engine (RAGE)
|
||||
|
||||
## GTA models and textures - RAGE resources
|
||||
# Note: GTA IV formats not yet documented - WAD, WBD, WBN, WHM, WPL
|
||||
|
||||
0 ulelong 0x00695254 GTA Drawable data (WDR), model and weapon data, used in GTA IV
|
||||
0 ulelong 0x00695238 GTA Windows Frag Type (WFT), vehicle models, used in GTA IV
|
||||
0 ulelong 0x006953A4 GTA Ped and LOD models (WDD), used in GTA IV
|
||||
0 ulelong 0x00695384 GTA Windows Texture Dictionary (WTD), used in GTA IV
|
||||
|
||||
## GTA text
|
||||
|
||||
4 string TABL GTA in-game text (GXT),
|
||||
>0 uleshort x version %d, used in GTA SA/IV
|
||||
0 string 2GXT GTA in-game text (GXT2), used in GTA V
|
||||
|
||||
## GTA scripts
|
||||
|
||||
0 ulelong 0x0d524353 GTA script (SCO), unencrypted, used in GTA IV,
|
||||
>4 ulelong x %d code bytes,
|
||||
>>8 ulelong x %d static variables,
|
||||
>>>12 ulelong x %d global variables
|
||||
0 ulelong 0x0e726373 GTA script (SCO), encrypted, used in GTA IV
|
||||
>4 ulelong x %d code bytes,
|
||||
>>8 ulelong x %d static variables,
|
||||
>>>12 ulelong x %d global variables
|
||||
|
||||
## GTA archives
|
||||
|
||||
0 ulelong 0xa94e2a52 GTA archive (IMG),
|
||||
>4 ulelong x version %d, used in GTA IV,
|
||||
>>8 ulelong x %d items
|
||||
|
||||
0 uleshort 0x5250 RAGE Package Format (RPF),
|
||||
>2 uleshort 0x4630 version 0, used in Rockstar Table Tennis,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
>2 uleshort 0x4632 version 2, used in GTA IV,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
>2 uleshort 0x4633 version 3, used in GTA IV Audio & Midnight Club: LA,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
>2 uleshort 0x4634 version 4, used in Max Payne 3,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
>2 uleshort 0x4636 version 6, used in RDR,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
>2 uleshort 0x4637 version 7, used in GTA V,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
>2 uleshort 0x4638 version 8, used in RDR 2,
|
||||
>>4 ulelong x %d bytes,
|
||||
>>>8 ulelong x %d entries
|
||||
|
13
external/bsd/file/dist/magic/magdir/jpeg
vendored
13
external/bsd/file/dist/magic/magdir/jpeg
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: jpeg,v 1.32 2018/10/01 18:58:29 christos Exp $
|
||||
# $File: jpeg,v 1.33 2021/03/21 15:04:50 christos Exp $
|
||||
# JPEG images
|
||||
# SunOS 5.5.1 had
|
||||
#
|
||||
@ -124,3 +124,14 @@
|
||||
>>4 lelong%2 0 JPEG-XR
|
||||
!:mime image/jxr
|
||||
!:ext jxr
|
||||
|
||||
# JPEG XL
|
||||
# From: Ian Tester
|
||||
0 string \xff\x0a JPEG XL codestream
|
||||
!:mime image/jxl
|
||||
!:ext jxl
|
||||
|
||||
# JPEG XL (transcoded JPEG file)
|
||||
0 string \x00\x00\x00\x0cJXL\x20\x0d\x0a\x87\x0a JPEG XL container
|
||||
!:mime image/jxl
|
||||
!:ext jxl
|
||||
|
30
external/bsd/file/dist/magic/magdir/linux
vendored
30
external/bsd/file/dist/magic/magdir/linux
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: linux,v 1.77 2021/02/24 23:05:02 christos Exp $
|
||||
# $File: linux,v 1.78 2021/04/04 17:46:17 christos Exp $
|
||||
# linux: file(1) magic for Linux files
|
||||
#
|
||||
# Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
|
||||
@ -83,20 +83,20 @@
|
||||
|
||||
# format v1, supported since 1998
|
||||
0 name linux-swap
|
||||
>0x400 lelong 1 little endian, version %u,
|
||||
>>0x404 lelong x size %u pages,
|
||||
>>0x408 lelong x %u bad pages,
|
||||
>0x400 belong 1 big endian, version %u,
|
||||
>>0x404 belong x size %u pages,
|
||||
>>0x408 belong x %u bad pages,
|
||||
>0x41c string \0 no label,
|
||||
>0x41c string >\0 LABEL=%s,
|
||||
>0x40c belong x UUID=%08x
|
||||
>0x410 beshort x \b-%04x
|
||||
>0x412 beshort x \b-%04x
|
||||
>0x414 beshort x \b-%04x
|
||||
>0x416 belong x \b-%08x
|
||||
>0x41a beshort x \b%04x
|
||||
>0x400 lelong 1 little endian, version %u,
|
||||
>>0x404 lelong x size %u pages,
|
||||
>>0x408 lelong x %u bad pages,
|
||||
>0x400 belong 1 big endian, version %u,
|
||||
>>0x404 belong x size %u pages,
|
||||
>>0x408 belong x %u bad pages,
|
||||
>0x41c string \0 no label,
|
||||
>0x41c string >\0 LABEL=%s,
|
||||
>0x40c ubelong x UUID=%08x
|
||||
>0x410 ubeshort x \b-%04x
|
||||
>0x412 ubeshort x \b-%04x
|
||||
>0x414 ubeshort x \b-%04x
|
||||
>0x416 ubelong x \b-%08x
|
||||
>0x41a ubeshort x \b%04x
|
||||
|
||||
0xff6 string SWAPSPACE2 Linux swap file, 4k page size,
|
||||
>0 use linux-swap
|
||||
|
@ -1,5 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: mail.news,v 1.26 2021/03/21 14:37:03 christos Exp $
|
||||
# $File: mail.news,v 1.27 2021/04/05 16:36:14 christos Exp $
|
||||
# mail.news: file(1) magic for mail and news
|
||||
#
|
||||
# Unfortunately, saved netnews also has From line added in some news software.
|
||||
@ -81,4 +81,4 @@
|
||||
# File format spec: https://wiki.dovecot.org/Design/Dcrypt/#File_format
|
||||
# From: Stephen Gildea
|
||||
0 string CRYPTED\003\007 Dovecot encrypted message
|
||||
>9 byte xu \b, dcrypt version %d
|
||||
>9 byte x \b, dcrypt version %d
|
||||
|
83
external/bsd/file/dist/magic/magdir/msdos
vendored
83
external/bsd/file/dist/magic/magdir/msdos
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: msdos,v 1.145 2021/02/23 00:51:10 christos Exp $
|
||||
# $File: msdos,v 1.147 2021/04/08 12:09:58 christos Exp $
|
||||
# msdos: file(1) magic for MS-DOS files
|
||||
#
|
||||
|
||||
@ -364,6 +364,87 @@
|
||||
>>49824 leshort =1 \b, 1 file
|
||||
>>49824 leshort >1 \b, %u files
|
||||
|
||||
# Summary: OS/2 LX Library and device driver (no DOS stub)
|
||||
# From: Joerg Jenderek
|
||||
# URL: http://en.wikipedia.org/wiki/EXE
|
||||
# Reference: http://www.textfiles.com/programming/FORMATS/lxexe.txt
|
||||
# https://github.com/open-watcom/open-watcom-v2/blob/master/bld/watcom/h/exeflat.h
|
||||
# Note: by dll-os2-no-dos-stub.trid.xml called "OS/2 Dynamic Link Library (no DOS stub)"
|
||||
# TODO: unify with DOS stub variant (MZ magic)
|
||||
0 string/b LX
|
||||
>2 ushort =0
|
||||
>>0 use lx-executable
|
||||
# no examples found for big endian variant
|
||||
>2 ushort =0x0101
|
||||
>>0 use \^lx-executable
|
||||
0 name lx-executable
|
||||
# similar looking like variant with MS-DOS stub (MZ magic): "MS-DOS executable, LX"
|
||||
#>0x00 uleshort x executable,
|
||||
# signature OSF_FLAT_LX_SIGNATURE~0x584C~LX OSF_FLAT_SIGNATURE~0x454C~LE
|
||||
>0x00 uleshort =0x584c LX
|
||||
>0x00 uleshort =0x454C LE
|
||||
>0x00 uleshort x executable
|
||||
#!:mime application/x-msdownload
|
||||
!:mime application/x-lx-executable
|
||||
# byte order: 00h~little-endian non-zero=1~big-endian
|
||||
#>0x02 ubyte =0 (little-endian)
|
||||
>0x02 ubyte !0 (big-endian)
|
||||
# FOR DEBUGGING!
|
||||
# word order: 00h~little-endian non-zero=1~big-endian
|
||||
#>0x03 ubyte =0 \b, little-endian word order
|
||||
#>0x03 ubyte !0 \b, big-endian word order
|
||||
# cpu_type; CPU type like: 1~286 2~386 3~486 4 20h~i860 21h~Intel N11 40h~MIPS R2000,R3000 41h~MIPS R6000 42h~MIPS R4000
|
||||
#>0x08 uleshort x \b, CPU %u
|
||||
# os_type; target operating system like: 0~unknown 1~OS/2 2~Windows 3~DOS 4.x 4~Windows 386
|
||||
#>0x0A leshort x \b, OS %u
|
||||
# flags; module type flags
|
||||
#>0x10 ulelong x \b, FLAGS 0x%8.8x
|
||||
# 00000002h ~Reserved for system use
|
||||
#>0x10 ulelong &0x00000002 \b, 2h reserved
|
||||
# OSF_INIT_INSTANCE=00000004h ~Per-Process Library Initialization; setting this bit for EXE file is invalid
|
||||
#>0x10 ulelong &0x00000004 \b, per-process library Initialization
|
||||
# OSF_INTERNAL_FIXUPS_DONE=00000010h ~Internal fixups for the module have been applied
|
||||
#>0x10 ulelong &0x00000010 \b, int. fixup
|
||||
# OSF_EXTERNAL_FIXUPS_DONE=00000020h ~External fixups for the module have been applied
|
||||
#>0x10 ulelong &0x00000020 \b, ext. fixup
|
||||
# OSF_NOT_PM_COMPATIBLE=00000100h ~Incompatible with PM windowing
|
||||
#>0x10 ulelong&0x00000100 =0x00000100 \b, incompatible with PM windowing
|
||||
# OSF_PM_COMPATIBLE=00000200h ~Compatible with PM windowing
|
||||
#>0x10 ulelong&0x00000200 =0x00000200 \b, compatible with PM windowing
|
||||
# bit 17; device driver
|
||||
#>0x10 ulelong&0x00020000 >0 \b, device driver
|
||||
# Per-process Library Termination; setting this bit for EXE file is invalid
|
||||
#>0x10 ulelong&0x40000000 =0x40000000 \b, per-process library termination
|
||||
>0x0a leshort 1 for OS/2
|
||||
# no example found
|
||||
>0x0a leshort 3 for DOS
|
||||
# http://www.ctyme.com/intr/rb-2939.htm#Table1610
|
||||
# library by module type mask 00038000h (bits 15-17);
|
||||
# 0h ~exectable Program module
|
||||
>0x10 ulelong&0x00038000 =0x00000000 (program)
|
||||
#!:ext exe
|
||||
# OSF_IS_DLL=8000h ~Library module (DLL)
|
||||
>0x10 ulelong&0x00038000 >0x00000000
|
||||
# OSF_PHYS_DEVICE=00020000h ~device driver
|
||||
>>0x10 ulelong&0x00020000 >0 (device driver)
|
||||
!:ext sys
|
||||
# if not device driver it is library (DLL)
|
||||
>>0x10 ulelong&0x00020000 =0 (library)
|
||||
!:ext dll
|
||||
# bits 8-10; OSF_PM_APP=300h in flags ~Uses PM windowing API; either it is GUI or console
|
||||
>0x10 ulelong&0x00000300 =0x00000300 (GUI)
|
||||
>0x10 ulelong&0x00000300 !0x00000300 (console)
|
||||
# CPU type
|
||||
>0x08 uleshort 1 i80286
|
||||
# all inspected examples
|
||||
>0x08 uleshort 2 i80386
|
||||
>0x08 uleshort 3 i80486
|
||||
>0x08 uleshort 4 i80586
|
||||
# 21h Intel "N11" or compatible
|
||||
# 40h MIPS Mark I ( R2000, R3000) or compatible
|
||||
# 41h MIPS Mark II ( R6000 ) or compatible
|
||||
# 42h MIPS Mark III ( R4000 ) or compatible
|
||||
|
||||
# added by Joerg Jenderek of https://www.freedos.org/software/?prog=kc
|
||||
# and https://www.freedos.org/software/?prog=kpdos
|
||||
# for FreeDOS files like KEYBOARD.SYS, KEYBRD2.SYS, KEYBRD3.SYS, *.KBD
|
||||
|
53
external/bsd/file/dist/magic/magdir/pgp
vendored
53
external/bsd/file/dist/magic/magdir/pgp
vendored
@ -1,54 +1,11 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: pgp,v 1.21 2020/03/20 17:11:05 christos Exp $
|
||||
# $File: pgp,v 1.24 2020/10/14 21:07:29 christos Exp $
|
||||
# pgp: file(1) magic for Pretty Good Privacy
|
||||
|
||||
# Handling of binary PGP keys is in pgp-binary-keys.
|
||||
# see https://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
|
||||
#
|
||||
# Update: Joerg Jenderek
|
||||
# Note: verified by `gpg -v --debug 0x02 --list-packets < PUBRING263_10.PGP`
|
||||
#0 byte 0x99 MAYBE PGP 0x99
|
||||
0 byte 0x99
|
||||
# 99h~10;0110;01~2=old packet type;tag 6=Public-Key Packet;1=two-octet length
|
||||
# A two-octet body header encodes packet lengths of 192~00C0h - 8383~20BFh
|
||||
#>1 ubeshort x \b, body length 0x%.4x
|
||||
# skip Basic.Image Beauty.320 Pic.Icons by looking for low version number
|
||||
#>3 ubyte x \b, V=%u
|
||||
#>3 ubyte <5 VERSION OK
|
||||
>3 ubyte <5
|
||||
# next packet type often b4h~(tag 13)~User ID Packet, b0h~(tag 12)~Trust packet
|
||||
#>>(1.S+3) ubyte x \b, next packet type 0x%x
|
||||
# skip 9900-v4.bin 9902-v4.bin by looking for valid second packet type (bit 7=1)
|
||||
#>>(1.S+3) ubyte >0x7F TYPE OK,
|
||||
>>(1.S+3) ubyte >0x7F
|
||||
# old versions 2,3 implies Pretty Good Privacy
|
||||
>>>3 ubyte <4 PGP key public ring (v%u)
|
||||
!:mime application/pgp-keys
|
||||
!:ext pgp/ASD
|
||||
>>>>4 beldate x created %s
|
||||
# days that this key is valid. If this number is zero, then it does not expire
|
||||
>>>>8 ubeshort >0 \b, %u days valid
|
||||
>>>>8 ubeshort =0 \b, not expire
|
||||
# display key algorithm 1~RSA (Encrypt or Sign)
|
||||
>>>>10 use key_algo
|
||||
# Multiprecision Integers (MPI) size
|
||||
>>>>11 ubeshort x %u bits
|
||||
# MPI
|
||||
>>>>13 ubequad x MPI=0x%16.16llx...
|
||||
# new version implies Pretty Good Privacy (PGP) >= 5.0 or Gnu Privacy Guard (GPG)
|
||||
>>>3 ubyte >3 PGP/GPG key public ring (v%u)
|
||||
!:mime application/pgp-keys
|
||||
!:ext pgp/gpg/pkr/asd
|
||||
>>>>4 beldate x created %s
|
||||
# display key algorithm 17~DSA
|
||||
>>>>8 use key_algo
|
||||
# Multiprecision Integers (MPI) size
|
||||
>>>>9 ubeshort x %u bits
|
||||
>>>>11 ubequad x MPI=0x%16.16llx...
|
||||
|
||||
0 beshort 0x9501 PGP key security ring
|
||||
!:mime application/x-pgp-keyring
|
||||
0 beshort 0x9500 PGP key security ring
|
||||
!:mime application/x-pgp-keyring
|
||||
0 beshort 0xa600 PGP encrypted data
|
||||
#!:mime application/pgp-encrypted
|
||||
#0 string -----BEGIN\040PGP text/PGP armored data
|
||||
@ -404,7 +361,7 @@
|
||||
# we branch into the proper key size
|
||||
# signatures defined as x{keysize}
|
||||
|
||||
>0 name pgpkey
|
||||
0 name pgpkey
|
||||
>0 string \x01\xd8 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xeb 1024b
|
||||
@ -582,8 +539,6 @@
|
||||
|
||||
# PGP RSA (e=65537) secret (sub-)key header
|
||||
|
||||
0 byte 0x95 PGP Secret Key -
|
||||
>1 use pgpkey
|
||||
0 byte 0x97 PGP Secret Sub-key -
|
||||
>1 use pgpkey
|
||||
0 byte 0x9d
|
||||
|
20
external/bsd/file/dist/magic/magdir/xenix
vendored
20
external/bsd/file/dist/magic/magdir/xenix
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: xenix,v 1.12 2021/02/23 00:51:10 christos Exp $
|
||||
# $File: xenix,v 1.13 2021/03/31 19:51:14 christos Exp $
|
||||
# xenix: file(1) magic for Microsoft Xenix
|
||||
#
|
||||
# "Middle model" stuff, and "Xenix 8086 relocatable or 80286 small
|
||||
@ -13,25 +13,35 @@
|
||||
#
|
||||
0 string core core file (Xenix)
|
||||
# URL: http://www.polarhome.com/service/man/?qf=86rel&tf=2&of=Xenix
|
||||
# http://fileformats.archiveteam.org/wiki/OMF
|
||||
# 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
|
||||
# GRR: line above is too general as it catches also Extensible storage engine DataBase,
|
||||
# all lif files like forth.lif hpcc88.lif lex90b.lif ( See ./lif)
|
||||
# and all compressed DEGAS low-res bitmaps like: MUNCHIE.PC1 PIDER1.PC1
|
||||
# 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 positive record length
|
||||
>>1 uleshort >0
|
||||
# skip examples like Xtable.Data FRACTAL.GEN SHR.VIEW by looking for positive 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)
|
||||
# skip examples like OMBRE.6 with "UUUUUU" name by looking for valid high second record type
|
||||
>>>>(1.s+3) ubyte >0x6D 8086 relocatable (Microsoft)
|
||||
#!:mime application/octet-stream
|
||||
!:mime application/x-object
|
||||
!:ext o/a
|
||||
!:ext obj/o/a
|
||||
# T-module name often source name like "hello.c" or "jmppm32.asm" in JMPPM32.OBJ or
|
||||
# "kbhit" in KBHITS.OBJ or "CAUSEWAY_KERNAL" in CWAPI.OBJ
|
||||
>>>>>3 pstring x \b, "%s"
|
||||
# data length probably lower 256 according to TrID obj_omf.trid.xml
|
||||
>>>>>1 uleshort x \b, 1st record data length %u
|
||||
# checksum
|
||||
#>>>>>(3.b+4) ubyte x \b, checksum 0x%2.2x
|
||||
# second recordtype: 96h~LNAMES 88h~COMENT 8CH~EXTDEF
|
||||
>>>>>(1.s+3) ubyte x \b, 2nd record type 0x%x
|
||||
>>>>>(1.s+4) uleshort x \b, 2nd record data length %u
|
||||
0 leshort 0xff65 x.out
|
||||
>2 string __.SYMDEF randomized
|
||||
>0 byte x archive
|
||||
|
2
external/bsd/file/dist/python/Makefile.in
vendored
2
external/bsd/file/dist/python/Makefile.in
vendored
@ -119,7 +119,7 @@ am__can_run_installinfo = \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in README
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgdatadir = @pkgdatadir@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
|
21
external/bsd/file/dist/src/apprentice.c
vendored
21
external/bsd/file/dist/src/apprentice.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: apprentice.c,v 1.25 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: apprentice.c,v 1.26 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -35,9 +35,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.297 2020/05/09 18:57:15 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.301 2021/02/23 00:51:11 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: apprentice.c,v 1.25 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: apprentice.c,v 1.26 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -549,6 +549,7 @@ file_ms_alloc(int flags)
|
||||
ms->elf_notes_max = FILE_ELF_NOTES_MAX;
|
||||
ms->regex_max = FILE_REGEX_MAX;
|
||||
ms->bytes_max = FILE_BYTES_MAX;
|
||||
ms->encoding_max = FILE_ENCODING_MAX;
|
||||
return ms;
|
||||
free:
|
||||
free(ms);
|
||||
@ -1467,7 +1468,10 @@ apprentice_load(struct magic_set *ms, const char *fn, int action)
|
||||
*/
|
||||
set_last_default(ms, mset[j].me, mset[j].count);
|
||||
|
||||
/* coalesce per file arrays into a single one */
|
||||
/* coalesce per file arrays into a single one, if needed */
|
||||
if (mset[j].count == 0)
|
||||
continue;
|
||||
|
||||
if (coalesce_entries(ms, mset[j].me, mset[j].count,
|
||||
&map->magic[j], &map->nmagic[j]) == -1) {
|
||||
errs++;
|
||||
@ -2138,6 +2142,13 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (m->type == FILE_NAME && cont_level != 0) {
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms, "`name%s' entries can only be "
|
||||
"declared at top level", l);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
|
||||
/* New and improved: ~ & | ^ + - * / % -- exciting, isn't it? */
|
||||
|
||||
@ -2747,7 +2758,7 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
|
||||
ull = CAST(uint64_t, strtoull(*p, &ep, 0));
|
||||
m->value.q = file_signextend(ms, m, ull);
|
||||
if (*p == ep) {
|
||||
file_magwarn(ms, "Unparseable number `%s'", *p);
|
||||
file_magwarn(ms, "Unparsable number `%s'", *p);
|
||||
} else {
|
||||
size_t ts = typesize(m->type);
|
||||
uint64_t x;
|
||||
|
31
external/bsd/file/dist/src/compress.c
vendored
31
external/bsd/file/dist/src/compress.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compress.c,v 1.20 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: compress.c,v 1.21 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -38,9 +38,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.127 2020/05/31 00:11:06 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.129 2020/12/08 21:26:00 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: compress.c,v 1.20 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: compress.c,v 1.21 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -77,7 +77,7 @@ typedef void (*sig_t)(int);
|
||||
#include <bzlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_XZLIB_H) && defined(XZLIBSUPPORT)
|
||||
#if defined(HAVE_LZMA_H) && defined(XZLIBSUPPORT)
|
||||
#define BUILTIN_XZLIB
|
||||
#include <lzma.h>
|
||||
#endif
|
||||
@ -850,8 +850,23 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
|
||||
for (i = 0; i < __arraycount(fdp); i++)
|
||||
fdp[i][0] = fdp[i][1] = -1;
|
||||
|
||||
if ((fd == -1 && pipe(fdp[STDIN_FILENO]) == -1) ||
|
||||
pipe(fdp[STDOUT_FILENO]) == -1 || pipe(fdp[STDERR_FILENO]) == -1) {
|
||||
/*
|
||||
* There are multithreaded users who run magic_file()
|
||||
* from dozens of threads. If two parallel magic_file() calls
|
||||
* analyze two large compressed files, both will spawn
|
||||
* an uncompressing child here, which writes out uncompressed data.
|
||||
* We read some portion, then close the pipe, then waitpid() the child.
|
||||
* If uncompressed data is larger, child shound get EPIPE and exit.
|
||||
* However, with *parallel* calls OTHER child may unintentionally
|
||||
* inherit pipe fds, thus keeping pipe open and making writes in
|
||||
* our child block instead of failing with EPIPE!
|
||||
* (For the bug to occur, two threads must mutually inherit their pipes,
|
||||
* and both must have large outputs. Thus it happens not that often).
|
||||
* To avoid this, be sure to create pipes with O_CLOEXEC.
|
||||
*/
|
||||
if ((fd == -1 && file_pipe_closexec(fdp[STDIN_FILENO]) == -1) ||
|
||||
file_pipe_closexec(fdp[STDOUT_FILENO]) == -1 ||
|
||||
file_pipe_closexec(fdp[STDERR_FILENO]) == -1) {
|
||||
closep(fdp[STDIN_FILENO]);
|
||||
closep(fdp[STDOUT_FILENO]);
|
||||
return makeerror(newch, n, "Cannot create pipe, %s",
|
||||
@ -882,16 +897,20 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
|
||||
if (fdp[STDIN_FILENO][1] > 2)
|
||||
(void) close(fdp[STDIN_FILENO][1]);
|
||||
}
|
||||
file_clear_closexec(STDIN_FILENO);
|
||||
|
||||
///FIXME: if one of the fdp[i][j] is 0 or 1, this can bomb spectacularly
|
||||
if (copydesc(STDOUT_FILENO, fdp[STDOUT_FILENO][1]))
|
||||
(void) close(fdp[STDOUT_FILENO][1]);
|
||||
if (fdp[STDOUT_FILENO][0] > 2)
|
||||
(void) close(fdp[STDOUT_FILENO][0]);
|
||||
file_clear_closexec(STDOUT_FILENO);
|
||||
|
||||
if (copydesc(STDERR_FILENO, fdp[STDERR_FILENO][1]))
|
||||
(void) close(fdp[STDERR_FILENO][1]);
|
||||
if (fdp[STDERR_FILENO][0] > 2)
|
||||
(void) close(fdp[STDERR_FILENO][0]);
|
||||
file_clear_closexec(STDERR_FILENO);
|
||||
|
||||
(void)execvp(compr[method].argv[0],
|
||||
RCAST(char *const *, RCAST(intptr_t, compr[method].argv)));
|
||||
|
6
external/bsd/file/dist/src/der.c
vendored
6
external/bsd/file/dist/src/der.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: der.c,v 1.6 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: der.c,v 1.7 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2016 Christos Zoulas
|
||||
@ -38,9 +38,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: der.c,v 1.20 2020/06/07 19:10:37 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: der.c,v 1.21 2020/06/15 00:58:10 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: der.c,v 1.6 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: der.c,v 1.7 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
|
240
external/bsd/file/dist/src/encoding.c
vendored
240
external/bsd/file/dist/src/encoding.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: encoding.c,v 1.9 2019/12/17 02:31:05 christos Exp $ */
|
||||
/* $NetBSD: encoding.c,v 1.10 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -38,9 +38,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: encoding.c,v 1.21 2019/06/08 20:49:14 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: encoding.c,v 1.27 2021/02/05 21:33:49 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: encoding.c,v 1.9 2019/12/17 02:31:05 christos Exp $");
|
||||
__RCSID("$NetBSD: encoding.c,v 1.10 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -49,14 +49,20 @@ __RCSID("$NetBSD: encoding.c,v 1.9 2019/12/17 02:31:05 christos Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *);
|
||||
private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *,
|
||||
private int looks_ascii(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_utf8_with_BOM(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_utf7(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_ucs16(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_ucs32(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_latin1(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_extended(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
private int looks_utf7(const unsigned char *, size_t, unichar *, size_t *);
|
||||
private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *);
|
||||
private int looks_ucs32(const unsigned char *, size_t, unichar *, size_t *);
|
||||
private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *);
|
||||
private int looks_extended(const unsigned char *, size_t, unichar *, size_t *);
|
||||
private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
|
||||
|
||||
#ifdef DEBUG_ENCODING
|
||||
@ -68,19 +74,20 @@ private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
|
||||
/*
|
||||
* Try to determine whether text is in some character code we can
|
||||
* identify. Each of these tests, if it succeeds, will leave
|
||||
* the text converted into one-unichar-per-character Unicode in
|
||||
* the text converted into one-file_unichar_t-per-character Unicode in
|
||||
* ubuf, and the number of characters converted in ulen.
|
||||
*/
|
||||
protected int
|
||||
file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf,
|
||||
size_t *ulen, const char **code, const char **code_mime, const char **type)
|
||||
file_encoding(struct magic_set *ms, const struct buffer *b,
|
||||
file_unichar_t **ubuf, size_t *ulen, const char **code,
|
||||
const char **code_mime, const char **type)
|
||||
{
|
||||
const unsigned char *buf = CAST(const unsigned char *, b->fbuf);
|
||||
size_t nbytes = b->flen;
|
||||
size_t mlen;
|
||||
int rv = 1, ucs_type;
|
||||
unsigned char *nbuf = NULL;
|
||||
unichar *udefbuf;
|
||||
file_unichar_t *udefbuf;
|
||||
size_t udeflen;
|
||||
|
||||
if (ubuf == NULL)
|
||||
@ -93,8 +100,12 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf,
|
||||
*code = "unknown";
|
||||
*code_mime = "binary";
|
||||
|
||||
if (nbytes > ms->encoding_max)
|
||||
nbytes = ms->encoding_max;
|
||||
|
||||
mlen = (nbytes + 1) * sizeof((*ubuf)[0]);
|
||||
if ((*ubuf = CAST(unichar *, calloc(CAST(size_t, 1), mlen))) == NULL) {
|
||||
*ubuf = CAST(file_unichar_t *, calloc(CAST(size_t, 1), mlen));
|
||||
if (*ubuf == NULL) {
|
||||
file_oomem(ms, mlen);
|
||||
goto done;
|
||||
}
|
||||
@ -108,7 +119,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf,
|
||||
if (looks_ascii(buf, nbytes, *ubuf, ulen)) {
|
||||
if (looks_utf7(buf, nbytes, *ubuf, ulen) > 0) {
|
||||
DPRINTF(("utf-7 %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
*code = "UTF-7 Unicode";
|
||||
*code = "Unicode text, UTF-7";
|
||||
*code_mime = "utf-7";
|
||||
} else {
|
||||
DPRINTF(("ascii %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
@ -117,27 +128,27 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf,
|
||||
}
|
||||
} else if (looks_utf8_with_BOM(buf, nbytes, *ubuf, ulen) > 0) {
|
||||
DPRINTF(("utf8/bom %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
*code = "UTF-8 Unicode (with BOM)";
|
||||
*code = "Unicode text, UTF-8 (with BOM)";
|
||||
*code_mime = "utf-8";
|
||||
} else if (file_looks_utf8(buf, nbytes, *ubuf, ulen) > 1) {
|
||||
DPRINTF(("utf8 %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
*code = "UTF-8 Unicode";
|
||||
*code = "Unicode text, UTF-8";
|
||||
*code_mime = "utf-8";
|
||||
} else if ((ucs_type = looks_ucs32(buf, nbytes, *ubuf, ulen)) != 0) {
|
||||
if (ucs_type == 1) {
|
||||
*code = "Little-endian UTF-32 Unicode";
|
||||
*code = "Unicode text, UTF-32, little-endian";
|
||||
*code_mime = "utf-32le";
|
||||
} else {
|
||||
*code = "Big-endian UTF-32 Unicode";
|
||||
*code = "Unicode text, UTF-32, big-endian";
|
||||
*code_mime = "utf-32be";
|
||||
}
|
||||
DPRINTF(("ucs32 %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
} else if ((ucs_type = looks_ucs16(buf, nbytes, *ubuf, ulen)) != 0) {
|
||||
if (ucs_type == 1) {
|
||||
*code = "Little-endian UTF-16 Unicode";
|
||||
*code = "Unicode text, UTF-16, little-endian";
|
||||
*code_mime = "utf-16le";
|
||||
} else {
|
||||
*code = "Big-endian UTF-16 Unicode";
|
||||
*code = "Unicode text, UTF-16, big-endian";
|
||||
*code_mime = "utf-16be";
|
||||
}
|
||||
DPRINTF(("ucs16 %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
@ -255,64 +266,40 @@ private char text_chars[256] = {
|
||||
I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
|
||||
};
|
||||
|
||||
private int
|
||||
looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf,
|
||||
size_t *ulen)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
*ulen = 0;
|
||||
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
int t = text_chars[buf[i]];
|
||||
|
||||
if (t != T)
|
||||
return 0;
|
||||
|
||||
ubuf[(*ulen)++] = buf[i];
|
||||
}
|
||||
|
||||
return 1;
|
||||
#define LOOKS(NAME, COND) \
|
||||
private int \
|
||||
looks_ ## NAME(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf, \
|
||||
size_t *ulen) \
|
||||
{ \
|
||||
size_t i, u; \
|
||||
unsigned char dist[256]; \
|
||||
memset(dist, 0, sizeof(dist)); \
|
||||
\
|
||||
*ulen = 0; \
|
||||
\
|
||||
for (i = 0; i < nbytes; i++) { \
|
||||
int t = text_chars[buf[i]]; \
|
||||
\
|
||||
if (COND) \
|
||||
return 0; \
|
||||
\
|
||||
ubuf[(*ulen)++] = buf[i]; \
|
||||
dist[buf[i]]++; \
|
||||
} \
|
||||
u = 0; \
|
||||
for (i = 0; i < __arraycount(dist); i++) { \
|
||||
if (dist[i]) \
|
||||
u++; \
|
||||
} \
|
||||
if (u < 3) \
|
||||
return 0; \
|
||||
\
|
||||
return 1; \
|
||||
}
|
||||
|
||||
private int
|
||||
looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
*ulen = 0;
|
||||
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
int t = text_chars[buf[i]];
|
||||
|
||||
if (t != T && t != I)
|
||||
return 0;
|
||||
|
||||
ubuf[(*ulen)++] = buf[i];
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int
|
||||
looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
|
||||
size_t *ulen)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
*ulen = 0;
|
||||
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
int t = text_chars[buf[i]];
|
||||
|
||||
if (t != T && t != I && t != X)
|
||||
return 0;
|
||||
|
||||
ubuf[(*ulen)++] = buf[i];
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
LOOKS(ascii, t != T)
|
||||
LOOKS(latin1, t != T && t != I)
|
||||
LOOKS(extended, t != T && t != I && t != X)
|
||||
|
||||
/*
|
||||
* Decide whether some text looks like UTF-8. Returns:
|
||||
@ -325,12 +312,65 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
|
||||
* If ubuf is non-NULL on entry, text is decoded into ubuf, *ulen;
|
||||
* ubuf must be big enough!
|
||||
*/
|
||||
|
||||
// from: https://golang.org/src/unicode/utf8/utf8.go
|
||||
|
||||
#define XX 0xF1 // invalid: size 1
|
||||
#define AS 0xF0 // ASCII: size 1
|
||||
#define S1 0x02 // accept 0, size 2
|
||||
#define S2 0x13 // accept 1, size 3
|
||||
#define S3 0x03 // accept 0, size 3
|
||||
#define S4 0x23 // accept 2, size 3
|
||||
#define S5 0x34 // accept 3, size 4
|
||||
#define S6 0x04 // accept 0, size 4
|
||||
#define S7 0x44 // accept 4, size 4
|
||||
|
||||
#define LOCB 0x80
|
||||
#define HICB 0xBF
|
||||
|
||||
// first is information about the first byte in a UTF-8 sequence.
|
||||
static const uint8_t first[] = {
|
||||
// 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x00-0x0F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x10-0x1F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x20-0x2F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x30-0x3F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x40-0x4F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x50-0x5F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x60-0x6F
|
||||
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x70-0x7F
|
||||
// 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0x80-0x8F
|
||||
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0x90-0x9F
|
||||
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0xA0-0xAF
|
||||
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0xB0-0xBF
|
||||
XX, XX, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, // 0xC0-0xCF
|
||||
S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, // 0xD0-0xDF
|
||||
S2, S3, S3, S3, S3, S3, S3, S3, S3, S3, S3, S3, S3, S4, S3, S3, // 0xE0-0xEF
|
||||
S5, S6, S6, S6, S7, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0xF0-0xFF
|
||||
};
|
||||
|
||||
// acceptRange gives the range of valid values for the second byte in a UTF-8
|
||||
// sequence.
|
||||
struct accept_range {
|
||||
uint8_t lo; // lowest value for second byte.
|
||||
uint8_t hi; // highest value for second byte.
|
||||
} accept_ranges[16] = {
|
||||
// acceptRanges has size 16 to avoid bounds checks in the code that uses it.
|
||||
{ LOCB, HICB },
|
||||
{ 0xA0, HICB },
|
||||
{ LOCB, 0x9F },
|
||||
{ 0x90, HICB },
|
||||
{ LOCB, 0x8F },
|
||||
};
|
||||
|
||||
protected int
|
||||
file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
|
||||
file_looks_utf8(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf,
|
||||
size_t *ulen)
|
||||
{
|
||||
size_t i;
|
||||
int n;
|
||||
unichar c;
|
||||
file_unichar_t c;
|
||||
int gotone = 0, ctrl = 0;
|
||||
|
||||
if (ubuf)
|
||||
@ -352,6 +392,11 @@ file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *
|
||||
return -1;
|
||||
} else { /* 11xxxxxx begins UTF-8 */
|
||||
int following;
|
||||
uint8_t x = first[buf[i]];
|
||||
const struct accept_range *ar =
|
||||
&accept_ranges[(unsigned int)x >> 4];
|
||||
if (x == XX)
|
||||
return -1;
|
||||
|
||||
if ((buf[i] & 0x20) == 0) { /* 110xxxxx */
|
||||
c = buf[i] & 0x1f;
|
||||
@ -376,6 +421,10 @@ file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *
|
||||
if (i >= nbytes)
|
||||
goto done;
|
||||
|
||||
if (n == 0 &&
|
||||
(buf[i] < ar->lo || buf[i] > ar->hi))
|
||||
return -1;
|
||||
|
||||
if ((buf[i] & 0x80) == 0 || (buf[i] & 0x40))
|
||||
return -1;
|
||||
|
||||
@ -397,8 +446,8 @@ done:
|
||||
* rest of the text.
|
||||
*/
|
||||
private int
|
||||
looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf,
|
||||
size_t *ulen)
|
||||
looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes,
|
||||
file_unichar_t *ubuf, size_t *ulen)
|
||||
{
|
||||
if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
|
||||
return file_looks_utf8(buf + 3, nbytes - 3, ubuf, ulen);
|
||||
@ -407,7 +456,8 @@ looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf,
|
||||
}
|
||||
|
||||
private int
|
||||
looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
|
||||
looks_utf7(const unsigned char *buf, size_t nbytes, file_unichar_t *ubuf,
|
||||
size_t *ulen)
|
||||
{
|
||||
if (nbytes > 4 && buf[0] == '+' && buf[1] == '/' && buf[2] == 'v')
|
||||
switch (buf[3]) {
|
||||
@ -426,7 +476,7 @@ looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
|
||||
}
|
||||
|
||||
private int
|
||||
looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf,
|
||||
looks_ucs16(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf,
|
||||
size_t *ulen)
|
||||
{
|
||||
int bigend;
|
||||
@ -449,10 +499,10 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf,
|
||||
|
||||
if (bigend)
|
||||
ubf[(*ulen)++] = bf[i + 1]
|
||||
| (CAST(unichar, bf[i]) << 8);
|
||||
| (CAST(file_unichar_t, bf[i]) << 8);
|
||||
else
|
||||
ubf[(*ulen)++] = bf[i]
|
||||
| (CAST(unichar, bf[i + 1]) << 8);
|
||||
| (CAST(file_unichar_t, bf[i + 1]) << 8);
|
||||
|
||||
if (ubf[*ulen - 1] == 0xfffe)
|
||||
return 0;
|
||||
@ -465,7 +515,7 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf,
|
||||
}
|
||||
|
||||
private int
|
||||
looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf,
|
||||
looks_ucs32(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf,
|
||||
size_t *ulen)
|
||||
{
|
||||
int bigend;
|
||||
@ -487,15 +537,15 @@ looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf,
|
||||
/* XXX fix to properly handle chars > 65536 */
|
||||
|
||||
if (bigend)
|
||||
ubf[(*ulen)++] = CAST(unichar, bf[i + 3])
|
||||
| (CAST(unichar, bf[i + 2]) << 8)
|
||||
| (CAST(unichar, bf[i + 1]) << 16)
|
||||
| (CAST(unichar, bf[i]) << 24);
|
||||
ubf[(*ulen)++] = CAST(file_unichar_t, bf[i + 3])
|
||||
| (CAST(file_unichar_t, bf[i + 2]) << 8)
|
||||
| (CAST(file_unichar_t, bf[i + 1]) << 16)
|
||||
| (CAST(file_unichar_t, bf[i]) << 24);
|
||||
else
|
||||
ubf[(*ulen)++] = CAST(unichar, bf[i + 0])
|
||||
| (CAST(unichar, bf[i + 1]) << 8)
|
||||
| (CAST(unichar, bf[i + 2]) << 16)
|
||||
| (CAST(unichar, bf[i + 3]) << 24);
|
||||
ubf[(*ulen)++] = CAST(file_unichar_t, bf[i + 0])
|
||||
| (CAST(file_unichar_t, bf[i + 1]) << 8)
|
||||
| (CAST(file_unichar_t, bf[i + 2]) << 16)
|
||||
| (CAST(file_unichar_t, bf[i + 3]) << 24);
|
||||
|
||||
if (ubf[*ulen - 1] == 0xfffe)
|
||||
return 0;
|
||||
|
15
external/bsd/file/dist/src/file.c
vendored
15
external/bsd/file/dist/src/file.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: file.c,v 1.15 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: file.c,v 1.16 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -35,9 +35,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: file.c,v 1.187 2020/06/07 17:38:30 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: file.c,v 1.189 2021/02/05 21:33:49 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: file.c,v 1.15 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: file.c,v 1.16 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -152,6 +152,8 @@ private struct {
|
||||
"max ELF prog sections processed" },
|
||||
{ "elf_shnum", MAGIC_PARAM_ELF_SHNUM_MAX, 0, 0, FILE_ELF_SHNUM_MAX,
|
||||
"max ELF sections processed" },
|
||||
{ "encoding", MAGIC_PARAM_ENCODING_MAX, 0, 0, FILE_ENCODING_MAX,
|
||||
"max bytes to scan for encoding" },
|
||||
{ "indir", MAGIC_PARAM_INDIR_MAX, 0, 0, FILE_INDIR_MAX,
|
||||
"recursion limit for indirection" },
|
||||
{ "name", MAGIC_PARAM_NAME_MAX, 0, 0, FILE_NAME_MAX,
|
||||
@ -529,8 +531,6 @@ unwrap(struct magic_set *ms, const char *fn)
|
||||
if (line[len - 1] == '\n')
|
||||
line[len - 1] = '\0';
|
||||
e |= process(ms, line, wid);
|
||||
if(nobuffer)
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
free(line);
|
||||
@ -562,11 +562,12 @@ process(struct magic_set *ms, const char *inname, int wid)
|
||||
|
||||
if (type == NULL) {
|
||||
(void)printf("ERROR: %s%c", magic_error(ms), c);
|
||||
return 1;
|
||||
} else {
|
||||
(void)printf("%s%c", type, c);
|
||||
return 0;
|
||||
}
|
||||
if (nobuffer)
|
||||
(void)fflush(stdout);
|
||||
return type == NULL;
|
||||
}
|
||||
|
||||
protected size_t
|
||||
|
35
external/bsd/file/dist/src/file.h
vendored
35
external/bsd/file/dist/src/file.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: file.h,v 1.25 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: file.h,v 1.26 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$File: file.h,v 1.220 2020/06/08 17:38:27 christos Exp $
|
||||
* @(#)$File: file.h,v 1.225 2021/02/05 22:29:07 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
@ -145,6 +145,14 @@
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
# define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#ifndef FD_CLOEXEC
|
||||
# define FD_CLOEXEC 1
|
||||
#endif
|
||||
|
||||
#define FILE_BADSIZE CAST(size_t, ~0ul)
|
||||
#define MAXDESC 64 /* max len of text description/MIME type */
|
||||
#define MAXMIME 80 /* max len of text MIME type */
|
||||
@ -412,14 +420,16 @@ struct level_info {
|
||||
#endif
|
||||
};
|
||||
|
||||
struct cont {
|
||||
size_t len;
|
||||
struct level_info *li;
|
||||
};
|
||||
|
||||
#define MAGIC_SETS 2
|
||||
|
||||
struct magic_set {
|
||||
struct mlist *mlist[MAGIC_SETS]; /* list of regular entries */
|
||||
struct cont {
|
||||
size_t len;
|
||||
struct level_info *li;
|
||||
} c;
|
||||
struct cont c;
|
||||
struct out {
|
||||
char *buf; /* Accumulation buffer */
|
||||
size_t blen; /* Length of buffer */
|
||||
@ -454,6 +464,7 @@ struct magic_set {
|
||||
uint16_t elf_notes_max;
|
||||
uint16_t regex_max;
|
||||
size_t bytes_max; /* number of bytes to read from file */
|
||||
size_t encoding_max; /* bytes to look for encoding */
|
||||
#ifndef FILE_BYTES_MAX
|
||||
# define FILE_BYTES_MAX (1024 * 1024) /* how much of the file to look at */
|
||||
#endif
|
||||
@ -463,10 +474,11 @@ struct magic_set {
|
||||
#define FILE_INDIR_MAX 50
|
||||
#define FILE_NAME_MAX 50
|
||||
#define FILE_REGEX_MAX 8192
|
||||
#define FILE_ENCODING_MAX (64 * 1024)
|
||||
};
|
||||
|
||||
/* Type for Unicode characters */
|
||||
typedef unsigned long unichar;
|
||||
typedef unsigned long file_unichar_t;
|
||||
|
||||
struct stat;
|
||||
#define FILE_T_LOCAL 1
|
||||
@ -500,9 +512,9 @@ protected int file_zmagic(struct magic_set *, const struct buffer *,
|
||||
protected int file_ascmagic(struct magic_set *, const struct buffer *,
|
||||
int);
|
||||
protected int file_ascmagic_with_encoding(struct magic_set *,
|
||||
const struct buffer *, unichar *, size_t, const char *, const char *, int);
|
||||
const struct buffer *, file_unichar_t *, size_t, const char *, const char *, int);
|
||||
protected int file_encoding(struct magic_set *, const struct buffer *,
|
||||
unichar **, size_t *, const char **, const char **, const char **);
|
||||
file_unichar_t **, size_t *, const char **, const char **, const char **);
|
||||
protected int file_is_json(struct magic_set *, const struct buffer *);
|
||||
protected int file_is_csv(struct magic_set *, const struct buffer *, int);
|
||||
protected int file_is_tar(struct magic_set *, const struct buffer *);
|
||||
@ -529,7 +541,7 @@ protected size_t file_mbswidth(const char *);
|
||||
protected const char *file_getbuffer(struct magic_set *);
|
||||
protected ssize_t sread(int, void *, size_t, int);
|
||||
protected int file_check_mem(struct magic_set *, unsigned int);
|
||||
protected int file_looks_utf8(const unsigned char *, size_t, unichar *,
|
||||
protected int file_looks_utf8(const unsigned char *, size_t, file_unichar_t *,
|
||||
size_t *);
|
||||
protected size_t file_pstring_length_size(struct magic_set *,
|
||||
const struct magic *);
|
||||
@ -540,6 +552,9 @@ protected char * file_printable(char *, size_t, const char *, size_t);
|
||||
protected int file_os2_apptype(struct magic_set *, const char *, const void *,
|
||||
size_t);
|
||||
#endif /* __EMX__ */
|
||||
protected int file_pipe_closexec(int *);
|
||||
protected int file_clear_closexec(int);
|
||||
protected char *file_strtrim(char *);
|
||||
|
||||
protected void buffer_init(struct buffer *, int, const struct stat *,
|
||||
const void *, size_t);
|
||||
|
70
external/bsd/file/dist/src/funcs.c
vendored
70
external/bsd/file/dist/src/funcs.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: funcs.c,v 1.18 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: funcs.c,v 1.19 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.115 2020/02/20 15:50:20 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.121 2021/02/05 22:29:07 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: funcs.c,v 1.18 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: funcs.c,v 1.19 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -42,6 +42,9 @@ __RCSID("$NetBSD: funcs.c,v 1.18 2020/06/15 00:37:24 christos Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for pipe2() */
|
||||
#endif
|
||||
#if defined(HAVE_WCHAR_H)
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
@ -99,7 +102,7 @@ file_checkfmt(char *msg, size_t mlen, const char *fmt)
|
||||
if (*++p == '%')
|
||||
continue;
|
||||
// Skip uninteresting.
|
||||
while (strchr("0.'+- ", *p) != NULL)
|
||||
while (strchr("#0.'+- ", *p) != NULL)
|
||||
p++;
|
||||
if (*p == '*') {
|
||||
if (msg)
|
||||
@ -251,11 +254,31 @@ file_badread(struct magic_set *ms)
|
||||
}
|
||||
|
||||
#ifndef COMPILE_ONLY
|
||||
#define FILE_SEPARATOR "\n- "
|
||||
|
||||
protected int
|
||||
file_separator(struct magic_set *ms)
|
||||
{
|
||||
return file_printf(ms, "\n- ");
|
||||
return file_printf(ms, FILE_SEPARATOR);
|
||||
}
|
||||
|
||||
static void
|
||||
trim_separator(struct magic_set *ms)
|
||||
{
|
||||
size_t l;
|
||||
|
||||
if (ms->o.buf == NULL)
|
||||
return;
|
||||
|
||||
l = strlen(ms->o.buf);
|
||||
if (l < sizeof(FILE_SEPARATOR))
|
||||
return;
|
||||
|
||||
l -= sizeof(FILE_SEPARATOR) - 1;
|
||||
if (strcmp(ms->o.buf + l, FILE_SEPARATOR) != 0)
|
||||
return;
|
||||
|
||||
ms->o.buf[l] = '\0';
|
||||
}
|
||||
|
||||
static int
|
||||
@ -459,6 +482,7 @@ simple:
|
||||
rv = -1;
|
||||
}
|
||||
done:
|
||||
trim_separator(ms);
|
||||
if ((ms->flags & MAGIC_MIME_ENCODING) != 0) {
|
||||
if (ms->flags & MAGIC_MIME_TYPE)
|
||||
if (file_printf(ms, "; charset=") == -1)
|
||||
@ -790,3 +814,39 @@ file_print_guid(char *str, size_t len, const uint64_t *guid)
|
||||
g->data4[2], g->data4[3], g->data4[4], g->data4[5],
|
||||
g->data4[6], g->data4[7]);
|
||||
}
|
||||
|
||||
protected int
|
||||
file_pipe_closexec(int *fds)
|
||||
{
|
||||
#ifdef HAVE_PIPE2
|
||||
return pipe2(fds, O_CLOEXEC);
|
||||
#else
|
||||
if (pipe(fds) == -1)
|
||||
return -1;
|
||||
(void)fcntl(fds[0], F_SETFD, FD_CLOEXEC);
|
||||
(void)fcntl(fds[1], F_SETFD, FD_CLOEXEC);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
protected int
|
||||
file_clear_closexec(int fd) {
|
||||
return fcntl(fd, F_SETFD, 0);
|
||||
}
|
||||
|
||||
protected char *
|
||||
file_strtrim(char *str)
|
||||
{
|
||||
char *last;
|
||||
|
||||
while (isspace(CAST(unsigned char, *str)))
|
||||
str++;
|
||||
last = str;
|
||||
while (*last)
|
||||
last++;
|
||||
--last;
|
||||
while (isspace(CAST(unsigned char, *last)))
|
||||
last--;
|
||||
*++last = '\0';
|
||||
return str;
|
||||
}
|
||||
|
8
external/bsd/file/dist/src/is_csv.c
vendored
8
external/bsd/file/dist/src/is_csv.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: is_csv.c,v 1.2 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: is_csv.c,v 1.3 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2019 Christos Zoulas
|
||||
@ -35,9 +35,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: is_csv.c,v 1.4 2019/06/26 20:31:31 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: is_csv.c,v 1.6 2020/08/09 16:43:36 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: is_csv.c,v 1.2 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: is_csv.c,v 1.3 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -155,7 +155,7 @@ file_is_csv(struct magic_set *ms, const struct buffer *b, int looks_text)
|
||||
return 1;
|
||||
|
||||
if (mime) {
|
||||
if (file_printf(ms, "application/csv") == -1)
|
||||
if (file_printf(ms, "text/csv") == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
17
external/bsd/file/dist/src/magic.c
vendored
17
external/bsd/file/dist/src/magic.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: magic.c,v 1.15 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: magic.c,v 1.16 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
@ -36,9 +36,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.112 2020/06/08 19:44:10 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.114 2021/02/05 21:33:49 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: magic.c,v 1.15 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: magic.c,v 1.16 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -442,7 +442,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
||||
_setmode(STDIN_FILENO, O_BINARY);
|
||||
#endif
|
||||
if (inname != NULL) {
|
||||
int flags = O_RDONLY|O_BINARY|O_NONBLOCK;
|
||||
int flags = O_RDONLY|O_BINARY|O_NONBLOCK|O_CLOEXEC;
|
||||
errno = 0;
|
||||
if ((fd = open(inname, flags)) < 0) {
|
||||
okstat = stat(inname, &sb) == 0;
|
||||
@ -466,6 +466,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
||||
rv = 0;
|
||||
goto done;
|
||||
}
|
||||
#if O_CLOEXEC == 0
|
||||
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fd != -1) {
|
||||
@ -620,6 +623,9 @@ magic_setparam(struct magic_set *ms, int param, const void *val)
|
||||
case MAGIC_PARAM_BYTES_MAX:
|
||||
ms->bytes_max = *CAST(const size_t *, val);
|
||||
return 0;
|
||||
case MAGIC_PARAM_ENCODING_MAX:
|
||||
ms->encoding_max = *CAST(const size_t *, val);
|
||||
return 0;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@ -653,6 +659,9 @@ magic_getparam(struct magic_set *ms, int param, void *val)
|
||||
case MAGIC_PARAM_BYTES_MAX:
|
||||
*CAST(size_t *, val) = ms->bytes_max;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ENCODING_MAX:
|
||||
*CAST(size_t *, val) = ms->encoding_max;
|
||||
return 0;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
125
external/bsd/file/dist/src/readelf.c
vendored
125
external/bsd/file/dist/src/readelf.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: readelf.c,v 1.24 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: readelf.c,v 1.25 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.173 2020/06/07 22:12:54 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.175 2020/12/17 20:43:37 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: readelf.c,v 1.24 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: readelf.c,v 1.25 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -360,7 +360,7 @@ 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;
|
||||
off_t ph_off = off, offs;
|
||||
int ph_num = num;
|
||||
|
||||
if (ms->flags & MAGIC_MIME)
|
||||
@ -383,8 +383,11 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
for ( ; num; num--) {
|
||||
if (pread(fd, xph_addr, xph_sizeof, off) <
|
||||
CAST(ssize_t, xph_sizeof)) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
if (file_printf(ms,
|
||||
", can't read elf program headers at %jd",
|
||||
(intmax_t)off) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
off += size;
|
||||
|
||||
@ -401,9 +404,12 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
* in the section.
|
||||
*/
|
||||
len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf);
|
||||
if ((bufsize = pread(fd, nbuf, len, xph_offset)) == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
offs = xph_offset;
|
||||
if ((bufsize = pread(fd, nbuf, len, offs)) == -1) {
|
||||
if (file_printf(ms, " can't read note section at %jd",
|
||||
(intmax_t)offs) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
offset = 0;
|
||||
for (;;) {
|
||||
@ -947,8 +953,12 @@ get_offset_from_virtaddr(struct magic_set *ms, int swap, int clazz, int fd,
|
||||
for ( ; num; num--) {
|
||||
if (pread(fd, xph_addr, xph_sizeof, off) <
|
||||
CAST(ssize_t, xph_sizeof)) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
if (file_printf(ms,
|
||||
", can't read elf program header at %jd",
|
||||
(intmax_t)off) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
}
|
||||
off += xph_sizeof;
|
||||
|
||||
@ -978,7 +988,9 @@ get_string_on_virtaddr(struct magic_set *ms,
|
||||
fsize, virtaddr);
|
||||
if (offset < 0 ||
|
||||
(buflen = pread(fd, buf, CAST(size_t, buflen), offset)) <= 0) {
|
||||
file_badread(ms);
|
||||
if (file_printf(ms, ", can't read elf string at %jd",
|
||||
(intmax_t)offset) == -1)
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1105,7 +1117,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
|
||||
|
||||
private size_t
|
||||
dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
|
||||
int clazz, int swap)
|
||||
int clazz, int swap, int *pie, size_t *need)
|
||||
{
|
||||
Elf32_Dyn dh32;
|
||||
Elf64_Dyn dh64;
|
||||
@ -1123,11 +1135,15 @@ dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
|
||||
|
||||
switch (xdh_tag) {
|
||||
case DT_FLAGS_1:
|
||||
*pie = 1;
|
||||
if (xdh_val & DF_1_PIE)
|
||||
ms->mode |= 0111;
|
||||
else
|
||||
ms->mode &= ~0111;
|
||||
break;
|
||||
case DT_NEEDED:
|
||||
(*need)++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1340,7 +1356,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
int stripped = 1, has_debug_info = 0;
|
||||
size_t nbadcap = 0;
|
||||
void *nbuf;
|
||||
off_t noff, coff, name_off;
|
||||
off_t noff, coff, name_off, offs;
|
||||
uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilities */
|
||||
uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilities */
|
||||
char name[50];
|
||||
@ -1361,9 +1377,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
}
|
||||
|
||||
/* Read offset of name section to be able to read section names later */
|
||||
if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab)))
|
||||
< CAST(ssize_t, xsh_sizeof)) {
|
||||
if (file_printf(ms, ", missing section headers") == -1)
|
||||
offs = CAST(off_t, (off + size * strtab));
|
||||
if (pread(fd, xsh_addr, xsh_sizeof, offs) < CAST(ssize_t, xsh_sizeof)) {
|
||||
if (file_printf(ms, ", missing section headers at %jd",
|
||||
(intmax_t)offs) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@ -1378,10 +1395,14 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
|
||||
for ( ; num; num--) {
|
||||
/* Read the name of this section. */
|
||||
if ((namesize = pread(fd, name, sizeof(name) - 1,
|
||||
name_off + xsh_name)) == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
offs = name_off + xsh_name;
|
||||
if ((namesize = pread(fd, name, sizeof(name) - 1, offs))
|
||||
== -1) {
|
||||
if (file_printf(ms,
|
||||
", can't read name of elf section at %jd",
|
||||
(intmax_t)offs) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
name[namesize] = '\0';
|
||||
if (strcmp(name, ".debug_info") == 0) {
|
||||
@ -1391,8 +1412,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
|
||||
if (pread(fd, xsh_addr, xsh_sizeof, off) <
|
||||
CAST(ssize_t, xsh_sizeof)) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
if (file_printf(ms, ", can't read elf section at %jd",
|
||||
(intmax_t)off) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
off += size;
|
||||
|
||||
@ -1433,11 +1456,15 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
" for note");
|
||||
return -1;
|
||||
}
|
||||
if (pread(fd, nbuf, xsh_size, xsh_offset) <
|
||||
offs = xsh_offset;
|
||||
if (pread(fd, nbuf, xsh_size, offs) <
|
||||
CAST(ssize_t, xsh_size)) {
|
||||
file_badread(ms);
|
||||
free(nbuf);
|
||||
return -1;
|
||||
if (file_printf(ms,
|
||||
", can't read elf note at %jd",
|
||||
(intmax_t)offs) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
noff = 0;
|
||||
@ -1614,9 +1641,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
}
|
||||
|
||||
/*
|
||||
* Look through the program headers of an executable image, searching
|
||||
* for a PT_INTERP section; if one is found, it's dynamically linked,
|
||||
* otherwise it's statically linked.
|
||||
* Look through the program headers of an executable image, to determine
|
||||
* if it is statically or dynamically linked. If it has a dynamic section,
|
||||
* it is pie, and does not have an interpreter or needed libraries, we
|
||||
* call it static pie.
|
||||
*/
|
||||
private int
|
||||
dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
@ -1625,12 +1653,13 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
{
|
||||
Elf32_Phdr ph32;
|
||||
Elf64_Phdr ph64;
|
||||
const char *linking_style = "statically";
|
||||
const char *linking_style;
|
||||
unsigned char nbuf[BUFSIZ];
|
||||
char ibuf[BUFSIZ];
|
||||
char interp[BUFSIZ];
|
||||
ssize_t bufsize;
|
||||
size_t offset, align, len;
|
||||
size_t offset, align, len, need = 0;
|
||||
int pie = 0, dynamic = 0;
|
||||
|
||||
if (num == 0) {
|
||||
if (file_printf(ms, ", no program header") == -1)
|
||||
@ -1648,8 +1677,11 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
int doread;
|
||||
if (pread(fd, xph_addr, xph_sizeof, off) <
|
||||
CAST(ssize_t, xph_sizeof)) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
if (file_printf(ms,
|
||||
", can't read elf program headers at %jd",
|
||||
(intmax_t)off) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
off += size;
|
||||
@ -1660,7 +1692,6 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
switch (xph_type) {
|
||||
case PT_DYNAMIC:
|
||||
doread = 1;
|
||||
linking_style = "dynamically";
|
||||
break;
|
||||
case PT_NOTE:
|
||||
if (sh_num) /* Did this through section headers */
|
||||
@ -1689,10 +1720,14 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
if (doread) {
|
||||
len = xph_filesz < sizeof(nbuf) ? xph_filesz
|
||||
: sizeof(nbuf);
|
||||
bufsize = pread(fd, nbuf, len, xph_offset);
|
||||
off_t offs = xph_offset;
|
||||
bufsize = pread(fd, nbuf, len, offs);
|
||||
if (bufsize == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
if (file_printf(ms,
|
||||
", can't read section at %jd",
|
||||
(intmax_t)offs) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
len = 0;
|
||||
@ -1700,6 +1735,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
/* Things we can determine when we seek */
|
||||
switch (xph_type) {
|
||||
case PT_DYNAMIC:
|
||||
dynamic = 1;
|
||||
offset = 0;
|
||||
// Let DF_1 determine if we are PIE or not.
|
||||
ms->mode &= ~0111;
|
||||
@ -1707,7 +1743,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
if (offset >= CAST(size_t, bufsize))
|
||||
break;
|
||||
offset = dodynamic(ms, nbuf, offset,
|
||||
CAST(size_t, bufsize), clazz, swap);
|
||||
CAST(size_t, bufsize), clazz, swap,
|
||||
&pie, &need);
|
||||
if (offset == 0)
|
||||
break;
|
||||
}
|
||||
@ -1716,6 +1753,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
break;
|
||||
|
||||
case PT_INTERP:
|
||||
need++;
|
||||
if (ms->flags & MAGIC_MIME)
|
||||
continue;
|
||||
if (bufsize && nbuf[0]) {
|
||||
@ -1750,8 +1788,15 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
}
|
||||
if (ms->flags & MAGIC_MIME)
|
||||
return 0;
|
||||
if (file_printf(ms, ", %s linked", linking_style)
|
||||
== -1)
|
||||
if (dynamic) {
|
||||
if (pie && need == 0)
|
||||
linking_style = "static-pie";
|
||||
else
|
||||
linking_style = "dynamically";
|
||||
} else {
|
||||
linking_style = "statically";
|
||||
}
|
||||
if (file_printf(ms, ", %s linked", linking_style) == -1)
|
||||
return -1;
|
||||
if (interp[0])
|
||||
if (file_printf(ms, ", interpreter %s",
|
||||
|
239
external/bsd/file/dist/src/softmagic.c
vendored
239
external/bsd/file/dist/src/softmagic.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: softmagic.c,v 1.23 2020/06/15 00:37:24 christos Exp $ */
|
||||
/* $NetBSD: softmagic.c,v 1.24 2021/04/09 19:11:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -35,9 +35,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.299 2020/06/07 21:58:01 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.309 2021/02/05 22:29:07 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: softmagic.c,v 1.23 2020/06/15 00:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: softmagic.c,v 1.24 2021/04/09 19:11:42 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -283,11 +283,9 @@ flush:
|
||||
goto flush;
|
||||
}
|
||||
|
||||
if (*m->desc)
|
||||
*found_match = 1;
|
||||
|
||||
if ((e = handle_annotation(ms, m, firstline)) != 0)
|
||||
{
|
||||
*found_match = 1;
|
||||
*need_separator = 1;
|
||||
*printed_something = 1;
|
||||
*returnval = 1;
|
||||
@ -298,14 +296,17 @@ flush:
|
||||
* If we are going to print something, we'll need to print
|
||||
* a blank before we print something else.
|
||||
*/
|
||||
if (print && *m->desc) {
|
||||
*need_separator = 1;
|
||||
*printed_something = 1;
|
||||
if (*m->desc) {
|
||||
*found_match = 1;
|
||||
*returnval = 1;
|
||||
if (print_sep(ms, firstline) == -1)
|
||||
return -1;
|
||||
if (mprint(ms, m) == -1)
|
||||
return -1;
|
||||
if (print) {
|
||||
*need_separator = 1;
|
||||
*printed_something = 1;
|
||||
if (print_sep(ms, firstline) == -1)
|
||||
return -1;
|
||||
if (mprint(ms, m) == -1)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (moffset(ms, m, &bb, &ms->c.li[cont_level].off)) {
|
||||
@ -396,16 +397,18 @@ flush:
|
||||
} else
|
||||
ms->c.li[cont_level].got_match = 1;
|
||||
|
||||
if (*m->desc)
|
||||
*found_match = 1;
|
||||
|
||||
if ((e = handle_annotation(ms, m, firstline))
|
||||
!= 0) {
|
||||
*found_match = 1;
|
||||
*need_separator = 1;
|
||||
*printed_something = 1;
|
||||
*returnval = 1;
|
||||
return e;
|
||||
}
|
||||
if (*m->desc) {
|
||||
*found_match = 1;
|
||||
*returnval = 1;
|
||||
}
|
||||
if (print && *m->desc) {
|
||||
/*
|
||||
* This continuation matched. Print
|
||||
@ -430,7 +433,6 @@ flush:
|
||||
if (file_printf(ms, " ") == -1)
|
||||
return -1;
|
||||
}
|
||||
*returnval = 1;
|
||||
*need_separator = 0;
|
||||
if (mprint(ms, m) == -1)
|
||||
return -1;
|
||||
@ -462,14 +464,23 @@ flush:
|
||||
firstline = 0;
|
||||
}
|
||||
if (*found_match) {
|
||||
if ((ms->flags & MAGIC_CONTINUE) == 0)
|
||||
return *returnval; /* don't keep searching */
|
||||
// So that we print a separator
|
||||
*printed_something = 0;
|
||||
firstline = 0;
|
||||
if ((ms->flags & MAGIC_CONTINUE) == 0)
|
||||
goto out;
|
||||
// So that we print a separator
|
||||
*printed_something = 0;
|
||||
firstline = 0;
|
||||
}
|
||||
cont_level = 0;
|
||||
}
|
||||
out:
|
||||
/*
|
||||
* If we are not printing (we are doing mime etc.)
|
||||
* and we did not find a mime entry, and we are at 0 level
|
||||
* we want to return 0 so that the default mime printer
|
||||
* takes over and prints "application/octet-stream"
|
||||
*/
|
||||
if (! print && ! *printed_something && ! *name_count)
|
||||
return 0;
|
||||
return *returnval; /* This is hit if -k is set or there is no match */
|
||||
}
|
||||
|
||||
@ -493,8 +504,8 @@ check_fmt(struct magic_set *ms, const char *fmt)
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if !defined(HAVE_STRNDUP) || defined(__aiws__)
|
||||
# ifdef __aiws__
|
||||
#if !defined(HAVE_STRNDUP) || defined(__aiws__) || defined(_AIX)
|
||||
# if defined(__aiws__) || defined(_AIX)
|
||||
# define strndup aix_strndup /* aix is broken */
|
||||
# endif
|
||||
char *strndup(const char *, size_t);
|
||||
@ -586,94 +597,57 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
else
|
||||
desc = ebuf;
|
||||
|
||||
#define PRINTER(value, format, stype, utype) \
|
||||
v = file_signextend(ms, m, CAST(uint64_t, value)); \
|
||||
switch (check_fmt(ms, desc)) { \
|
||||
case -1: \
|
||||
return -1; \
|
||||
case 1: \
|
||||
if (m->flag & UNSIGNED) { \
|
||||
(void)snprintf(buf, sizeof(buf), "%" format "u", \
|
||||
CAST(utype, v)); \
|
||||
} else { \
|
||||
(void)snprintf(buf, sizeof(buf), "%" format "d", \
|
||||
CAST(stype, v)); \
|
||||
} \
|
||||
if (file_printf(ms, F(ms, desc, "%s"), buf) == -1) \
|
||||
return -1; \
|
||||
break; \
|
||||
default: \
|
||||
if (m->flag & UNSIGNED) { \
|
||||
if (file_printf(ms, F(ms, desc, "%" format "u"), \
|
||||
CAST(utype, v)) == -1) \
|
||||
return -1; \
|
||||
} else { \
|
||||
if (file_printf(ms, F(ms, desc, "%" format "d"), \
|
||||
CAST(stype, v)) == -1) \
|
||||
return -1; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
t = ms->offset + sizeof(stype); \
|
||||
break
|
||||
|
||||
switch (m->type) {
|
||||
case FILE_BYTE:
|
||||
v = file_signextend(ms, m, CAST(uint64_t, p->b));
|
||||
switch (check_fmt(ms, desc)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 1:
|
||||
(void)snprintf(buf, sizeof(buf), "%d",
|
||||
CAST(unsigned char, v));
|
||||
if (file_printf(ms, F(ms, desc, "%s"), buf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, F(ms, desc, "%d"),
|
||||
CAST(unsigned char, v)) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
t = ms->offset + sizeof(char);
|
||||
break;
|
||||
PRINTER(p->b, "", int8_t, uint8_t);
|
||||
|
||||
case FILE_SHORT:
|
||||
case FILE_BESHORT:
|
||||
case FILE_LESHORT:
|
||||
v = file_signextend(ms, m, CAST(uint64_t, p->h));
|
||||
switch (check_fmt(ms, desc)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 1:
|
||||
(void)snprintf(buf, sizeof(buf), "%u",
|
||||
CAST(unsigned short, v));
|
||||
if (file_printf(ms, F(ms, desc, "%s"), buf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, F(ms, desc, "%u"),
|
||||
CAST(unsigned short, v)) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
t = ms->offset + sizeof(short);
|
||||
break;
|
||||
PRINTER(p->h, "", int16_t, uint16_t);
|
||||
|
||||
case FILE_LONG:
|
||||
case FILE_BELONG:
|
||||
case FILE_LELONG:
|
||||
case FILE_MELONG:
|
||||
v = file_signextend(ms, m, CAST(uint64_t, p->l));
|
||||
switch (check_fmt(ms, desc)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 1:
|
||||
(void)snprintf(buf, sizeof(buf), "%u",
|
||||
CAST(uint32_t, v));
|
||||
if (file_printf(ms, F(ms, desc, "%s"), buf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, F(ms, desc, "%u"),
|
||||
CAST(uint32_t, v)) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
t = ms->offset + sizeof(int32_t);
|
||||
break;
|
||||
PRINTER(p->l, "", int32_t, uint32_t);
|
||||
|
||||
case FILE_QUAD:
|
||||
case FILE_BEQUAD:
|
||||
case FILE_LEQUAD:
|
||||
case FILE_OFFSET:
|
||||
v = file_signextend(ms, m, p->q);
|
||||
switch (check_fmt(ms, desc)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 1:
|
||||
(void)snprintf(buf, sizeof(buf), "%" INT64_T_FORMAT "u",
|
||||
CAST(unsigned long long, v));
|
||||
if (file_printf(ms, F(ms, desc, "%s"), buf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, F(ms, desc, "%" INT64_T_FORMAT "u"),
|
||||
CAST(unsigned long long, v)) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
t = ms->offset + sizeof(int64_t);
|
||||
break;
|
||||
PRINTER(p->q, INT64_T_FORMAT, long long, unsigned long long);
|
||||
|
||||
case FILE_STRING:
|
||||
case FILE_PSTRING:
|
||||
@ -695,19 +669,9 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
if (*m->value.s == '\0')
|
||||
str[strcspn(str, "\r\n")] = '\0';
|
||||
|
||||
if (m->str_flags & STRING_TRIM) {
|
||||
char *last;
|
||||
while (isspace(CAST(unsigned char, *str)))
|
||||
str++;
|
||||
last = str;
|
||||
while (*last)
|
||||
last++;
|
||||
--last;
|
||||
while (isspace(CAST(unsigned char, *last)))
|
||||
last--;
|
||||
*++last = '\0';
|
||||
}
|
||||
|
||||
if (m->str_flags & STRING_TRIM)
|
||||
str = file_strtrim(str);
|
||||
|
||||
if (file_printf(ms, F(ms, desc, "%s"),
|
||||
file_printable(sbuf, sizeof(sbuf), str,
|
||||
sizeof(p->s) - (str - p->s))) == -1)
|
||||
@ -812,7 +776,7 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
|
||||
case FILE_SEARCH:
|
||||
case FILE_REGEX: {
|
||||
char *cp;
|
||||
char *cp, *scp;
|
||||
int rval;
|
||||
|
||||
cp = strndup(RCAST(const char *, ms->search.s),
|
||||
@ -821,8 +785,10 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
file_oomem(ms, ms->search.rm_len);
|
||||
return -1;
|
||||
}
|
||||
scp = (m->str_flags & STRING_TRIM) ? file_strtrim(cp) : cp;
|
||||
|
||||
rval = file_printf(ms, F(ms, desc, "%s"),
|
||||
file_printable(sbuf, sizeof(sbuf), cp, ms->search.rm_len));
|
||||
file_printable(sbuf, sizeof(sbuf), scp, ms->search.rm_len));
|
||||
free(cp);
|
||||
|
||||
if (rval == -1)
|
||||
@ -976,6 +942,7 @@ moffset(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
||||
case FILE_DEFAULT:
|
||||
case FILE_INDIRECT:
|
||||
case FILE_OFFSET:
|
||||
case FILE_USE:
|
||||
o = ms->offset;
|
||||
break;
|
||||
|
||||
@ -1562,6 +1529,28 @@ normal:
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int
|
||||
save_cont(struct magic_set *ms, struct cont *c)
|
||||
{
|
||||
size_t len;
|
||||
*c = ms->c;
|
||||
len = c->len * sizeof(*c->li);
|
||||
ms->c.li = CAST(struct level_info *, malloc(len));
|
||||
if (ms->c.li == NULL) {
|
||||
ms->c = *c;
|
||||
return -1;
|
||||
}
|
||||
memcpy(ms->c.li, c->li, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void
|
||||
restore_cont(struct magic_set *ms, struct cont *c)
|
||||
{
|
||||
free(ms->c.li);
|
||||
ms->c = *c;
|
||||
}
|
||||
|
||||
private int
|
||||
mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
||||
const unsigned char *s, size_t nbytes, size_t o, unsigned int cont_level,
|
||||
@ -1569,14 +1558,15 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
||||
int *printed_something, int *need_separator, int *returnval,
|
||||
int *found_match)
|
||||
{
|
||||
uint32_t offset = ms->offset;
|
||||
uint32_t eoffset, offset = ms->offset;
|
||||
struct buffer bb;
|
||||
intmax_t lhs;
|
||||
file_pushbuf_t *pb;
|
||||
int rv, oneed_separator, in_type;
|
||||
int rv, oneed_separator, in_type, nfound_match;
|
||||
char *rbuf;
|
||||
union VALUETYPE *p = &ms->ms_value;
|
||||
struct mlist ml;
|
||||
struct cont c;
|
||||
|
||||
if (*indir_count >= ms->indir_max) {
|
||||
file_error(ms, 0, "indirect count (%hu) exceeded",
|
||||
@ -1882,16 +1872,32 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
||||
file_error(ms, 0, "cannot find entry `%s'", rbuf);
|
||||
return -1;
|
||||
}
|
||||
(*name_count)++;
|
||||
if (save_cont(ms, &c) == -1) {
|
||||
file_error(ms, errno, "can't allocate continuation");
|
||||
return -1;
|
||||
}
|
||||
|
||||
oneed_separator = *need_separator;
|
||||
if (m->flag & NOSPACE)
|
||||
*need_separator = 0;
|
||||
|
||||
nfound_match = 0;
|
||||
(*name_count)++;
|
||||
eoffset = ms->eoffset;
|
||||
rv = match(ms, ml.magic, ml.nmagic, b, offset + o,
|
||||
mode, text, flip, indir_count, name_count,
|
||||
printed_something, need_separator, returnval, found_match);
|
||||
printed_something, need_separator, returnval,
|
||||
&nfound_match);
|
||||
ms->ms_value.q = nfound_match;
|
||||
(*name_count)--;
|
||||
*found_match |= nfound_match;
|
||||
|
||||
restore_cont(ms, &c);
|
||||
|
||||
if (rv != 1)
|
||||
*need_separator = oneed_separator;
|
||||
ms->offset = offset;
|
||||
ms->eoffset = eoffset;
|
||||
return rv;
|
||||
|
||||
case FILE_NAME:
|
||||
@ -2235,9 +2241,10 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case FILE_INDIRECT:
|
||||
case FILE_USE:
|
||||
return ms->ms_value.q != 0;
|
||||
case FILE_NAME:
|
||||
case FILE_INDIRECT:
|
||||
return 1;
|
||||
case FILE_DER:
|
||||
matched = der_cmp(ms, m);
|
||||
|
18
external/bsd/file/dist/tests/Makefile.in
vendored
18
external/bsd/file/dist/tests/Makefile.in
vendored
@ -324,6 +324,14 @@ zstd-v0.8-22.testfile \
|
||||
zstd-v0.8-23.testfile \
|
||||
zstd-v0.8-F4.testfile \
|
||||
zstd-v0.8-FF.testfile \
|
||||
pgp-binary-key-v2-phil.testfile \
|
||||
pgp-binary-key-v3-lutz.testfile \
|
||||
pgp-binary-key-v4-dsa.testfile \
|
||||
pgp-binary-key-v4-ecc-no-userid-secret.testfile \
|
||||
pgp-binary-key-v4-ecc-secret-key.testfile \
|
||||
pgp-binary-key-v4-rsa-key.testfile \
|
||||
pgp-binary-key-v4-rsa-no-userid-secret.testfile \
|
||||
pgp-binary-key-v4-rsa-secret-key.testfile \
|
||||
CVE-2014-1943.result \
|
||||
JW07022A.mp3.result \
|
||||
escapevel.result \
|
||||
@ -362,7 +370,15 @@ zstd-v0.8-21.result \
|
||||
zstd-v0.8-22.result \
|
||||
zstd-v0.8-23.result \
|
||||
zstd-v0.8-F4.result \
|
||||
zstd-v0.8-FF.result
|
||||
zstd-v0.8-FF.result \
|
||||
pgp-binary-key-v2-phil.result \
|
||||
pgp-binary-key-v3-lutz.result \
|
||||
pgp-binary-key-v4-dsa.result \
|
||||
pgp-binary-key-v4-ecc-no-userid-secret.result \
|
||||
pgp-binary-key-v4-ecc-secret-key.result \
|
||||
pgp-binary-key-v4-rsa-key.result \
|
||||
pgp-binary-key-v4-rsa-no-userid-secret.result \
|
||||
pgp-binary-key-v4-rsa-secret-key.result
|
||||
|
||||
T = $(top_srcdir)/tests
|
||||
all: all-am
|
||||
|
9
external/bsd/file/include/config.h
vendored
9
external/bsd/file/include/config.h
vendored
@ -126,6 +126,9 @@
|
||||
/* Define to 1 if you have the `newlocale' function. */
|
||||
#define HAVE_NEWLOCALE 1
|
||||
|
||||
/* Define to 1 if you have the `pipe2' function. */
|
||||
#define HAVE_PIPE2 1
|
||||
|
||||
/* Define to 1 if you have the `pread' function. */
|
||||
#define HAVE_PREAD 1
|
||||
|
||||
@ -277,7 +280,7 @@
|
||||
#define PACKAGE_NAME "file"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "file 5.39"
|
||||
#define PACKAGE_STRING "file 5.40"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "file"
|
||||
@ -286,7 +289,7 @@
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "5.39"
|
||||
#define PACKAGE_VERSION "5.40"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
@ -317,7 +320,7 @@
|
||||
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "5.39"
|
||||
#define VERSION "5.40"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
|
Loading…
Reference in New Issue
Block a user