git: 17886a892b30 - stable/12 - file: upgrade to 5.41.

From: Xin LI <delphij_at_FreeBSD.org>
Date: Tue, 18 Jan 2022 00:44:46 UTC
The branch stable/12 has been updated by delphij:

URL: https://cgit.FreeBSD.org/src/commit/?id=17886a892b307c7b2c8a3ee6148567ce5ade6884

commit 17886a892b307c7b2c8a3ee6148567ce5ade6884
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2022-01-04 06:02:42 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2022-01-18 00:44:36 +0000

    file: upgrade to 5.41.
    
    (cherry picked from commit 43a5ec4eb41567cc92586503212743d89686d78f)
---
 contrib/file/ChangeLog                             |  78 +++
 contrib/file/Makefile.am                           |   2 +-
 contrib/file/Makefile.in                           |   7 +-
 contrib/file/README                                | 159 -----
 contrib/file/README.DEVELOPER                      |  49 ++
 contrib/file/RELEASE-PROCEDURE                     |  29 +
 contrib/file/acinclude.m4                          |  35 +-
 contrib/file/aclocal.m4                            |  79 +--
 contrib/file/config.h.in                           |   3 +
 contrib/file/configure                             | 608 +++--------------
 contrib/file/configure.ac                          |   7 +-
 contrib/file/doc/Makefile.in                       |   3 +-
 contrib/file/doc/file.man                          |  61 +-
 contrib/file/doc/magic.man                         |   9 +-
 contrib/file/ltmain.sh                             |   0
 contrib/file/m4/visibility.m4                      |  77 +++
 contrib/file/magic/Magdir/acorn                    |  10 +-
 contrib/file/magic/Magdir/aes                      |  29 +
 contrib/file/magic/Magdir/algol68                  |  42 +-
 contrib/file/magic/Magdir/amigaos                  | 147 +++-
 contrib/file/magic/Magdir/android                  |  33 +-
 contrib/file/magic/Magdir/animation                | 163 ++++-
 contrib/file/magic/Magdir/apple                    |  10 +-
 contrib/file/magic/Magdir/archive                  | 207 ++++--
 contrib/file/magic/Magdir/arm                      |  41 ++
 contrib/file/magic/Magdir/asf                      |   6 +-
 contrib/file/magic/Magdir/audio                    |  64 +-
 contrib/file/magic/Magdir/avm                      |  33 +
 contrib/file/magic/Magdir/biosig                   |   2 +-
 contrib/file/magic/Magdir/blit                     |   6 +-
 contrib/file/magic/Magdir/bm                       |  10 +
 contrib/file/magic/Magdir/bsi                      |   7 +-
 contrib/file/magic/Magdir/bytecode                 |  30 +
 contrib/file/magic/Magdir/c-lang                   |   7 +-
 contrib/file/magic/Magdir/c64                      |  13 +-
 contrib/file/magic/Magdir/cad                      | 109 ++-
 contrib/file/magic/Magdir/cafebabe                 |  61 +-
 contrib/file/magic/Magdir/citrus                   |   6 +-
 contrib/file/magic/Magdir/clipper                  |   6 +-
 contrib/file/magic/Magdir/coff                     |  78 ++-
 contrib/file/magic/Magdir/commands                 | 100 +--
 contrib/file/magic/Magdir/compress                 |   9 +-
 contrib/file/magic/Magdir/console                  |  62 +-
 contrib/file/magic/Magdir/coverage                 |   4 +-
 contrib/file/magic/Magdir/crypto                   |   5 +
 contrib/file/magic/Magdir/database                 | 212 +++++-
 contrib/file/magic/Magdir/der                      |   7 +-
 contrib/file/magic/Magdir/diff                     |  15 +-
 contrib/file/magic/Magdir/digital                  |   3 +-
 contrib/file/magic/Magdir/editors                  |   6 +-
 contrib/file/magic/Magdir/elf                      |  45 +-
 contrib/file/magic/Magdir/espressif                |   4 +-
 contrib/file/magic/Magdir/filesystems              | 297 +++++----
 contrib/file/magic/Magdir/fonts                    |  33 +-
 contrib/file/magic/Magdir/forth                    |  46 +-
 contrib/file/magic/Magdir/fsav                     |  12 +-
 contrib/file/magic/Magdir/games                    | 215 +++++-
 contrib/file/magic/Magdir/git                      |   8 +-
 contrib/file/magic/Magdir/gnome                    |   6 +-
 contrib/file/magic/Magdir/gnu                      |  42 +-
 contrib/file/magic/Magdir/gpt                      |   4 +-
 contrib/file/magic/Magdir/gpu                      |  10 +-
 contrib/file/magic/Magdir/guile                    |  13 -
 contrib/file/magic/Magdir/hitachi-sh               |   6 +-
 contrib/file/magic/Magdir/human68k                 |   4 +-
 contrib/file/magic/Magdir/ibm370                   |   6 +-
 contrib/file/magic/Magdir/ibm6000                  |   4 +-
 contrib/file/magic/Magdir/icc                      |  26 +-
 contrib/file/magic/Magdir/iff                      |  10 +-
 contrib/file/magic/Magdir/images                   | 736 +++++++++++++++++----
 contrib/file/magic/Magdir/intel                    |   6 +-
 contrib/file/magic/Magdir/jpeg                     |  25 +-
 contrib/file/magic/Magdir/lammps                   |  64 ++
 contrib/file/magic/Magdir/lif                      |  45 +-
 contrib/file/magic/Magdir/linux                    |  79 ++-
 contrib/file/magic/Magdir/lisp                     |   5 +-
 contrib/file/magic/Magdir/locoscript               |  12 +
 contrib/file/magic/Magdir/lua                      |  11 +-
 contrib/file/magic/Magdir/mach                     | 140 ++--
 contrib/file/magic/Magdir/macintosh                |  18 +-
 contrib/file/magic/Magdir/mail.news                |  11 +-
 contrib/file/magic/Magdir/map                      | 112 ++--
 contrib/file/magic/Magdir/maple                    |  58 +-
 contrib/file/magic/Magdir/mathematica              |  95 ++-
 contrib/file/magic/Magdir/measure                  |   7 +-
 contrib/file/magic/Magdir/misctools                |  35 +-
 contrib/file/magic/Magdir/modem                    |   4 +-
 contrib/file/magic/Magdir/motorola                 |   4 +-
 contrib/file/magic/Magdir/mozilla                  |   6 +-
 contrib/file/magic/Magdir/msdos                    | 313 +++++++--
 contrib/file/magic/Magdir/msooxml                  |  23 +-
 contrib/file/magic/Magdir/msx                      |  68 +-
 contrib/file/magic/Magdir/neko                     |  12 -
 contrib/file/magic/Magdir/netware                  |   6 +-
 contrib/file/magic/Magdir/nim-lang                 |  29 +
 contrib/file/magic/Magdir/ole2compounddocs         |  71 +-
 contrib/file/magic/Magdir/os2                      | 137 +++-
 contrib/file/magic/Magdir/pcjr                     |   8 +
 contrib/file/magic/Magdir/pdf                      |  11 +-
 contrib/file/magic/Magdir/pgf                      |   6 +-
 contrib/file/magic/Magdir/pgp                      |  59 +-
 contrib/file/magic/Magdir/pgp-binary-keys          | 388 +++++++++++
 contrib/file/magic/Magdir/plan9                    |  11 +-
 contrib/file/magic/Magdir/pmem                     |  18 +-
 contrib/file/magic/Magdir/puzzle                   |  17 +
 contrib/file/magic/Magdir/python                   | 208 +++---
 contrib/file/magic/Magdir/riff                     | 364 +++++++++-
 contrib/file/magic/Magdir/rtf                      |   4 +-
 contrib/file/magic/Magdir/sccs                     |  12 +-
 contrib/file/magic/Magdir/sgi                      |  20 +-
 contrib/file/magic/Magdir/sgml                     |   4 +-
 contrib/file/magic/Magdir/sinclair                 |   4 +-
 contrib/file/magic/Magdir/sniffer                  |   8 +-
 contrib/file/magic/Magdir/sosi                     |   4 +-
 contrib/file/magic/Magdir/spectrum                 |   4 +-
 contrib/file/magic/Magdir/sql                      | 110 ++-
 contrib/file/magic/Magdir/statistics               |  45 ++
 contrib/file/magic/Magdir/terminfo                 |   4 +-
 contrib/file/magic/Magdir/timezone                 |  22 +-
 contrib/file/magic/Magdir/tplink                   |  26 +-
 contrib/file/magic/Magdir/uf2                      |  72 ++
 contrib/file/magic/Magdir/virtual                  |  84 +--
 contrib/file/magic/Magdir/vorbis                   |   8 +-
 contrib/file/magic/Magdir/windows                  | 213 +++---
 contrib/file/magic/Magdir/wordprocessors           |  31 +-
 contrib/file/magic/Magdir/wsdl                     |   4 +-
 contrib/file/magic/Magdir/xenix                    |  26 +-
 contrib/file/magic/Magdir/xilinx                   |   4 +-
 contrib/file/magic/Magdir/xwindows                 |  10 +-
 contrib/file/magic/Magdir/yara                     |   4 +-
 contrib/file/magic/Magdir/zfs                      |   4 +-
 contrib/file/magic/Magdir/zip                      |  14 +-
 contrib/file/magic/Makefile.am                     |  29 +-
 contrib/file/magic/Makefile.in                     |  31 +-
 contrib/file/magic/scripts/create_filemagic_flac   |  71 ++
 contrib/file/python/CHANGELOG.md                   |   5 +
 contrib/file/python/Makefile.am                    |   2 +-
 contrib/file/python/Makefile.in                    |   5 +-
 contrib/file/python/file_magic/__init__.py         |   1 +
 contrib/file/python/magic.py                       |  75 ++-
 contrib/file/src/BNF                               | 151 +++++
 contrib/file/src/Makefile.am                       |   2 +-
 contrib/file/src/Makefile.in                       |   5 +-
 contrib/file/src/apprentice.c                      |  86 ++-
 contrib/file/src/ascmagic.c                        |  76 ++-
 contrib/file/src/cdf.c                             |  29 +-
 contrib/file/src/cdf.mk                            |   3 +
 contrib/file/src/compress.c                        |  27 +-
 contrib/file/src/der.c                             |   3 +-
 contrib/file/src/encoding.c                        | 225 ++++---
 contrib/file/src/file.c                            |  43 +-
 contrib/file/src/file.h                            |  46 +-
 contrib/file/src/file_opts.h                       |   2 +-
 contrib/file/src/funcs.c                           |  76 ++-
 contrib/file/src/is_csv.c                          |   7 +-
 contrib/file/src/magic.c                           |  15 +-
 contrib/file/src/magic.h.in                        |   1 +
 contrib/file/src/memtest.c                         | 143 ++++
 contrib/file/src/print.c                           |  14 +-
 contrib/file/src/readelf.c                         | 141 ++--
 contrib/file/src/seccomp.c                         |  16 +-
 contrib/file/src/softmagic.c                       | 276 ++++----
 contrib/file/src/vasprintf.c                       |  12 +-
 contrib/file/tests/JW07022A.mp3.result             |   2 +-
 contrib/file/tests/Makefile.am                     |  94 ++-
 contrib/file/tests/Makefile.in                     |  97 ++-
 contrib/file/tests/android-vdex-1.result           |   1 +
 contrib/file/tests/android-vdex-1.testfile         | Bin 0 -> 20 bytes
 contrib/file/tests/android-vdex-2.result           |   1 +
 contrib/file/tests/android-vdex-2.testfile         | Bin 0 -> 20 bytes
 contrib/file/tests/bcachefs.result                 |   1 +
 contrib/file/tests/bcachefs.testfile               | Bin 0 -> 8192 bytes
 contrib/file/tests/cl8m8ocofedso.result            |   1 +
 contrib/file/tests/cl8m8ocofedso.testfile          | Bin 0 -> 27777 bytes
 contrib/file/tests/ext4.result                     |   1 +
 contrib/file/tests/ext4.testfile                   | Bin 0 -> 2048 bytes
 contrib/file/tests/matilde.arm.result              |   1 +
 contrib/file/tests/matilde.arm.testfile            | Bin 0 -> 14790 bytes
 contrib/file/tests/pcjr.result                     |   1 +
 contrib/file/tests/pcjr.testfile                   | Bin 0 -> 514 bytes
 contrib/file/tests/pgp-binary-key-v2-phil.result   |   1 +
 contrib/file/tests/pgp-binary-key-v2-phil.testfile | Bin 0 -> 975 bytes
 contrib/file/tests/pgp-binary-key-v3-lutz.result   |   1 +
 contrib/file/tests/pgp-binary-key-v3-lutz.testfile | Bin 0 -> 11722 bytes
 contrib/file/tests/pgp-binary-key-v4-dsa.result    |   1 +
 contrib/file/tests/pgp-binary-key-v4-dsa.testfile  | Bin 0 -> 1677 bytes
 .../pgp-binary-key-v4-ecc-no-userid-secret.result  |   1 +
 ...pgp-binary-key-v4-ecc-no-userid-secret.testfile | Bin 0 -> 794 bytes
 .../tests/pgp-binary-key-v4-ecc-secret-key.result  |   1 +
 .../pgp-binary-key-v4-ecc-secret-key.testfile      | Bin 0 -> 494 bytes
 .../file/tests/pgp-binary-key-v4-rsa-key.result    |   1 +
 .../file/tests/pgp-binary-key-v4-rsa-key.testfile  | Bin 0 -> 3695 bytes
 .../pgp-binary-key-v4-rsa-no-userid-secret.result  |   1 +
 ...pgp-binary-key-v4-rsa-no-userid-secret.testfile | Bin 0 -> 5907 bytes
 .../tests/pgp-binary-key-v4-rsa-secret-key.result  |   1 +
 .../pgp-binary-key-v4-rsa-secret-key.testfile      | Bin 0 -> 3695 bytes
 contrib/file/tests/test.c                          |  90 ++-
 contrib/file/tests/uf2.result                      |   1 +
 contrib/file/tests/uf2.testfile                    | Bin 0 -> 512 bytes
 lib/libmagic/config.h                              |   9 +-
 200 files changed, 6716 insertions(+), 2713 deletions(-)

diff --git a/contrib/file/ChangeLog b/contrib/file/ChangeLog
index f877ad22da6a..0bb334c9fd88 100644
--- a/contrib/file/ChangeLog
+++ b/contrib/file/ChangeLog
@@ -1,3 +1,81 @@
+2021-10-18  11:57  Christos Zoulas <christos@zoulas.com>
+
+	* release 5.41
+
+2021-09-23  03:51  Christos Zoulas <christos@zoulas.com>
+
+	* Avinash Sonawane: Fix tzname detection
+
+2021-09-03  09:17  Christos Zoulas <christos@zoulas.com>
+
+	* Fix relationship tests with "search" magic, don't short circuit
+	  logic
+
+2021-07-13  01:06  Christos Zoulas <christos@zoulas.com>
+
+	* Fix memory leak in compile mode
+
+2021-07-01  03:51  Christos Zoulas <christos@zoulas.com>
+
+	* PR/272: kiefermat: Only set returnval = 1 when we printed something
+	  (in all cases print or !print). This simplifies the logic and fixes
+	  the issue in the PR with -k and --mime-type there was no continuation
+	  printed before the default case.
+
+2021-06-30  13:07  Christos Zoulas <christos@zoulas.com>
+
+	* PR/270: Don't translate unprintable characters in %s magic formats
+	  when -r
+	* PR/269: Avoid undefined behavior with clang (adding offset to NULL)
+
+2021-05-09  18:38  Christos Zoulas <christos@zoulas.com>
+
+	* Add a new flag (f) that requires that the match is a full word,
+	   not a partial word match.
+	* Add varint types (unused)
+
+2021-04-19  17:17  Christos Zoulas <christos@zoulas.com>
+
+	* PR/256: mutableVoid: If the file is less than 3 bytes, use the file
+	  length to determine type
+	* PR/259: aleksandr.v.novichkov: mime printing through indirect magic
+	  is not taken into account, use match directly so that it does.
+
+2021-04-04  17:02  Christos Zoulas <christos@zoulas.com>
+
+	* count the total bytes found not the total byte positions
+	  in order to determine encoding (Anatol Belski)
+
+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
diff --git a/contrib/file/Makefile.am b/contrib/file/Makefile.am
index 2ab67ed7bae5..b10b1cb14daa 100644
--- a/contrib/file/Makefile.am
+++ b/contrib/file/Makefile.am
@@ -1,6 +1,6 @@
 ACLOCAL_AMFLAGS = -I m4
 
-EXTRA_DIST = MAINT
+EXTRA_DIST = MAINT RELEASE-PROCEDURE README.DEVELOPER m4/visibility.m4
 
 SUBDIRS = src magic tests doc python
 
diff --git a/contrib/file/Makefile.in b/contrib/file/Makefile.in
index e19b15e1bfdc..79e1d05b5d73 100644
--- a/contrib/file/Makefile.in
+++ b/contrib/file/Makefile.in
@@ -92,7 +92,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -191,7 +192,7 @@ CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
 	$(srcdir)/libmagic.pc.in AUTHORS COPYING ChangeLog INSTALL \
-	NEWS README TODO compile config.guess config.sub install-sh \
+	NEWS TODO compile config.guess config.sub depcomp install-sh \
 	ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
@@ -357,7 +358,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = MAINT
+EXTRA_DIST = MAINT RELEASE-PROCEDURE README.DEVELOPER m4/visibility.m4
 SUBDIRS = src magic tests doc python
 
 # This variable must have 'exec' in its name, in order to be installed
diff --git a/contrib/file/README b/contrib/file/README
deleted file mode 100644
index f69dc43e0fb1..000000000000
--- a/contrib/file/README
+++ /dev/null
@@ -1,159 +0,0 @@
-## README for file(1) Command and the libmagic(3) library ##
-
-    @(#) $File: README,v 1.59 2019/09/19 01:04:01 christos Exp $
-
-Mailing List: file@astron.com
-Mailing List archives: http://mailman.astron.com/pipermail/file/
-Bug tracker: http://bugs.astron.com/
-E-mail: christos@astron.com
-Build Status: https://travis-ci.org/file/file
-
-Phone: Do not even think of telephoning me about this program. Send cash first!
-
-This is Release 5.x of Ian Darwin's (copyright but distributable)
-file(1) command, an implementation of the Unix File(1) command.
-It knows the 'magic number' of several thousands of file types.
-This version is the standard "file" command for Linux,
-*BSD, and other systems. (See "patchlevel.h" for the exact release number).
-
-You can download the latest version of the original sources for file from:
-
-	ftp://ftp.astron.com/pub/file/
-
-A public read-only git repository of the same sources is available at:
-
-	https://github.com/file/file
-
-We are continuously being fuzzed by OSS-FUZZ:
-
-	https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:file
-
-The major changes for 5.x are CDF file parsing, indirect magic, name/use
-(recursion) and overhaul in mime and ascii encoding handling.
-
-The major feature of 4.x is the refactoring of the code into a library,
-and the re-write of the file command in terms of that library. The library
-itself, libmagic can be used by 3rd party programs that wish to identify
-file types without having to fork() and exec() file. The prime contributor
-for 4.0 was Mans Rullgard.
-
-UNIX is a trademark of UNIX System Laboratories.
-
-The prime contributor to Release 3.8 was Guy Harris, who put in megachanges
-including byte-order independence.
-
-The prime contributor to Release 3.0 was Christos Zoulas, who put
-in hundreds of lines of source code changes, including his own
-ANSIfication of the code (I liked my own ANSIfication better, but
-his (__P()) is the "Berkeley standard" way of doing it, and I wanted UCB
-to include the code...), his HP-like "indirection" (a feature of
-the HP file command, I think), and his mods that finally got the
-uncompress (-z) mode finished and working.
-
-This release has compiled in numerous environments; see PORTING
-for a list and problems.
-
-This fine freeware file(1) follows the USG (System V) model of the file
-command, rather than the Research (V7) version or the V7-derived 4.[23]
-Berkeley one. That is, the file /etc/magic contains much of the ritual
-information that is the source of this program's power. My version
-knows a little more magic (including tar archives) than System V; the
-/etc/magic parsing seems to be compatible with the (poorly documented)
-System V /etc/magic format (with one exception; see the man page).
-
-In addition, the /etc/magic file is built from a subdirectory
-for easier(?) maintenance.  I will act as a clearinghouse for
-magic numbers assigned to all sorts of data files that
-are in reasonable circulation. Send your magic numbers,
-in magic(5) format please, to the maintainer, Christos Zoulas.
-
-COPYING - read this first.
-README - read this second (you are currently reading this file).
-INSTALL - read on how to install
-src/apprentice.c - parses /etc/magic to learn magic
-src/apptype.c - used for OS/2 specific application type magic
-src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
-src/asctime_r.c - replacement for OS's that don't have it.
-src/asprintf.c - replacement for OS's that don't have it.
-src/asctime_r.c - replacement for OS's that don't have it.
-src/asprintf.c - replacement for OS's that don't have it.
-src/buffer.c - buffer handling functions.
-src/cdf.[ch] - parser for Microsoft Compound Document Files
-src/cdf_time.c - time converter for CDF.
-src/compress.c - handles decompressing files to look inside.
-src/ctime_r.c - replacement for OS's that don't have it.
-src/der.[ch] - parser for Distinguished Encoding Rules
-src/dprintf.c - replacement for OS's that don't have it.
-src/elfclass.h - common code for elf 32/64.
-src/encoding.c - handles unicode encodings
-src/file.c - the main program
-src/file.h - header file
-src/file_opts.h - list of options
-src/fmtcheck.c - replacement for OS's that don't have it.
-src/fsmagic.c - first set of tests the program runs, based on filesystem info
-src/funcs.c - utilility functions
-src/getline.c - replacement for OS's that don't have it.
-src/getopt_long.c - replacement for OS's that don't have it.
-src/gmtime_r.c - replacement for OS's that don't have it.
-src/is_csv.c - knows about Comma Separated Value file format (RFC 4180).
-src/is_json.c - knows about JavaScript Object Notation format (RFC 8259).
-src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).
-src/localtime_r.c - replacement for OS's that don't have it.
-src/magic.h.in - source file for magic.h
-src/mygetopt.h - replacement for OS's that don't have it.
-src/magic.c - the libmagic api
-src/names.h - header file for ascmagic.c
-src/pread.c - replacement for OS's that don't have it.
-src/print.c - print results, errors, warnings.
-src/readcdf.c - CDF wrapper.
-src/readelf.[ch] - Stand-alone elf parsing code.
-src/softmagic.c - 2nd set of tests, based on /etc/magic
-src/mygetopt.h - replacement for OS's that don't have it.
-src/strcasestr.c - replacement for OS's that don't have it.
-src/strlcat.c - replacement for OS's that don't have it.
-src/strlcpy.c - replacement for OS's that don't have it.
-src/strndup.c - replacement for OS's that don't have it.
-src/tar.h - tar file definitions
-src/vasprintf.c - for systems that don't have it.
-doc/file.man - man page for the command
-doc/magic.man - man page for the magic file, courtesy Guy Harris.
-	Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
-
-Magdir - directory of /etc/magic pieces
-------------------------------------------------------------------------------
-
-If you submit a new magic entry please make sure you read the following
-guidelines:
-
-- Initial match is preferably at least 32 bits long, and is a _unique_ match
-- If this is not feasible, use additional check
-- Match of <= 16 bits are not accepted
-- Delay printing string as much as possible, don't print output too early
-- Avoid printf arbitrary byte as string, which can be a source of
-  crash and buffer overflow
-
-- Provide complete information with entry:
-  * One line short summary
-  * Optional long description
-  * File extension, if applicable
-  * Full name and contact method (for discussion when entry has problem)
-  * Further reference, such as documentation of format
-
-------------------------------------------------------------------------------
-
-gpg for dummies:
-
-$ gpg --verify file-X.YY.tar.gz.asc file-X.YY.tar.gz
-gpg: assuming signed data in `file-X.YY.tar.gz'
-gpg: Signature made WWW MMM DD HH:MM:SS YYYY ZZZ using DSA key ID KKKKKKKK
-
-To download the key:
-
-$ gpg --keyserver hkp://keys.gnupg.net --recv-keys KKKKKKKK
-
-------------------------------------------------------------------------------
-
-
-Parts of this software were developed at SoftQuad Inc., developers
-of SGML/HTML/XML publishing software, in Toronto, Canada.
-SoftQuad was swallowed up by Corel in 2002 and does not exist any longer.
diff --git a/contrib/file/README.DEVELOPER b/contrib/file/README.DEVELOPER
new file mode 100644
index 000000000000..dfe27b973e8e
--- /dev/null
+++ b/contrib/file/README.DEVELOPER
@@ -0,0 +1,49 @@
+# How to get started developing
+
+@(#) $File: README.DEVELOPER,v 1.9 2021/09/20 14:04:39 christos Exp $
+
+## Auto files
+
+After checking out the source, run the following:
+
+	autoreconf -f -i
+	make distclean	# this can fail if you have not built before
+	./configure --disable-silent-rules
+	make -j4
+	make -C tests check
+
+If you see errors, make sure you have the latest libtool and autoconf
+This has been tested with autoconf-2.69 and libtool-2.4.2
+
+## Installing dependencies
+
+If your platform doesn't have the above tools, install the following
+packages first.
+
+### Debian
+
+	apt-get install \
+	    automake \
+	    gcc \
+	    libtool \
+	    make \
+	    python \
+	    zlib1g-dev \
+
+See also `.travis.yml`.
+
+### Mac OS X (MacPorts)
+
+	port install \
+	    autoconf \
+	    automake \
+	    libtool \
+
+### Mac OS X (HomeBrew)
+
+	brew install autoconf automake libtool
+
+Tested with:
+	autoconf 2.69
+	automake 1.16.1
+	libtool 2.4.6
diff --git a/contrib/file/RELEASE-PROCEDURE b/contrib/file/RELEASE-PROCEDURE
new file mode 100644
index 000000000000..af6ed0fe2b0f
--- /dev/null
+++ b/contrib/file/RELEASE-PROCEDURE
@@ -0,0 +1,29 @@
+# HOW TO RELEASE FILE
+
+@(#) $File: RELEASE-PROCEDURE,v 1.7 2021/10/18 16:38:25 christos Exp $
+
+1)  Update version number in configure.ac
+2)  Note the new version in ChangeLog
+3)  Update README.md if applicable
+4)  Commit changes into CVS
+5)  Rebuild and run tests (see README.DEVELOPER)
+6)  Tag the release with FILEx_yy
+7)  Create the source tarball: make distcheck
+7a) Sign the source tarball.
+	gpg --armor --detach-sign mysoftware-0.4.tar.gz
+8)  Make the source tarball available on ftp
+9)  Add the new version to bugs.astron.com:
+    - Click: Manage > Manage Projects > file
+    - Scroll down to "Versions"
+    - Click on "Edit" next to the HEAD version
+    - Change the "Version" from HEAD to the newly released version
+    - Change the "Date Order" to the current time
+    - Check the "Released" box
+    - Click on "Update Version"
+    - Type HEAD into the box at the bottom of the version list and
+      click on "Add and Edit Version"
+    - Set the "Date Order" to 2030-01-01 (i.e. far in the future)
+    - Click on "Update Version"
+10) Mail an announcement to file@astron.com containing a summary of the
+    ChangeLog changes. Historically we don't mention magic changes in the
+    ChangeLog or the mail message, only source changes.
diff --git a/contrib/file/acinclude.m4 b/contrib/file/acinclude.m4
index dcbf92f50308..77b63ff5cb7b 100644
--- a/contrib/file/acinclude.m4
+++ b/contrib/file/acinclude.m4
@@ -3,8 +3,9 @@ dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
 AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
 [AC_REQUIRE([AC_STRUCT_TM])dnl
 AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
+[AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([#include <sys/types.h>
+#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;])],
   ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
 if test "$ac_cv_struct_tm_zone" = yes; then
   AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE])
@@ -14,19 +15,20 @@ fi
 # consider it declared and we won't give our own extern.
 AC_CHECK_DECLS([tzname], , , [#include <time.h>])
 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
-[AC_TRY_LINK(
-[#include <time.h>
-#if !HAVE_DECL_TZNAME
+[AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([#include <time.h>],
+[[#if !HAVE_DECL_TZNAME
 extern char *tzname[];
-#endif],
-[return tzname[0][0];], [ac_cv_var_tzname=yes], [ac_cv_var_tzname=no])])
+#endif
+return tzname[0][0];]])], [ac_cv_var_tzname=yes], [ac_cv_var_tzname=no])])
   if test $ac_cv_var_tzname = yes; then
     AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME])
   fi
 
 AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_isdst;],
+[AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([#include <sys/types.h>
+#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_isdst;])],
   ac_cv_struct_tm_isdst=yes, ac_cv_struct_tm_isdst=no)])
 if test "$ac_cv_struct_tm_isdst" = yes; then
   AC_DEFINE(HAVE_TM_ISDST,1,[HAVE_TM_ISDST])
@@ -35,14 +37,12 @@ fi
 
 AC_CHECK_DECLS([daylight], , , [#include <time.h>])
 AC_CACHE_CHECK(for daylight, ac_cv_var_daylight,
-[AC_TRY_LINK(
-changequote(<<, >>)dnl
-<<#include <time.h>
-#if !HAVE_DECL_DAYLIGHT
+[AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([#include <time.h>],
+[#if !HAVE_DECL_DAYLIGHT
 extern int daylight;
-#endif>>,
-changequote([, ])dnl
-[atoi(daylight);], ac_cv_var_daylight=yes, ac_cv_var_daylight=no)])
+#endif
+atoi(daylight);])], ac_cv_var_daylight=yes, ac_cv_var_daylight=no)])
   if test $ac_cv_var_daylight = yes; then
     AC_DEFINE(HAVE_DAYLIGHT,1,[HAVE_DAYLIGHT])
   fi
@@ -50,7 +50,8 @@ changequote([, ])dnl
 
 AC_DEFUN([AC_STRUCT_OPTION_GETOPT_H],
 [AC_CACHE_CHECK([for struct option in getopt], ac_cv_struct_option_getopt_h,
-[AC_TRY_COMPILE([#include <getopt.h>], [struct option op; op.name;],
+[AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([#include <getopt.h>], [struct option op; op.name;])],
   ac_cv_struct_option_getopt_h=yes, ac_cv_struct_option_getopt_h=no)])
 if test "$ac_cv_struct_option_getopt_h" = yes; then
   AC_DEFINE(HAVE_STRUCT_OPTION,1,[HAVE_STRUCT_OPTION])
diff --git a/contrib/file/aclocal.m4 b/contrib/file/aclocal.m4
index 08b67b8e7771..41732229cdad 100644
--- a/contrib/file/aclocal.m4
+++ b/contrib/file/aclocal.m4
@@ -20,84 +20,6 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# visibility.m4 serial 6
-dnl Copyright (C) 2005, 2008, 2010-2019 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-
-dnl Tests whether the compiler supports the command-line option
-dnl -fvisibility=hidden and the function and variable attributes
-dnl __attribute__((__visibility__("hidden"))) and
-dnl __attribute__((__visibility__("default"))).
-dnl Does *not* test for __visibility__("protected") - which has tricky
-dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
-dnl Mac OS X.
-dnl Does *not* test for __visibility__("internal") - which has processor
-dnl dependent semantics.
-dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
-dnl "really only recommended for legacy code".
-dnl Set the variable CFLAG_VISIBILITY.
-dnl Defines and sets the variable HAVE_VISIBILITY.
-
-AC_DEFUN([gl_VISIBILITY],
-[
-  AC_REQUIRE([AC_PROG_CC])
-  CFLAG_VISIBILITY=
-  HAVE_VISIBILITY=0
-  if test -n "$GCC"; then
-    dnl First, check whether -Werror can be added to the command line, or
-    dnl whether it leads to an error because of some other option that the
-    dnl user has put into $CC $CFLAGS $CPPFLAGS.
-    AC_CACHE_CHECK([whether the -Werror option is usable],
-      [gl_cv_cc_vis_werror],
-      [gl_save_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS -Werror"
-       AC_COMPILE_IFELSE(
-         [AC_LANG_PROGRAM([[]], [[]])],
-         [gl_cv_cc_vis_werror=yes],
-         [gl_cv_cc_vis_werror=no])
-       CFLAGS="$gl_save_CFLAGS"
-      ])
-    dnl Now check whether visibility declarations are supported.
-    AC_CACHE_CHECK([for simple visibility declarations],
-      [gl_cv_cc_visibility],
-      [gl_save_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS -fvisibility=hidden"
-       dnl We use the option -Werror and a function dummyfunc, because on some
-       dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
-       dnl "visibility attribute not supported in this configuration; ignored"
-       dnl at the first function definition in every compilation unit, and we
-       dnl don't want to use the option in this case.
-       if test $gl_cv_cc_vis_werror = yes; then
-         CFLAGS="$CFLAGS -Werror"
-       fi
-       AC_COMPILE_IFELSE(
-         [AC_LANG_PROGRAM(
-            [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
-              extern __attribute__((__visibility__("default"))) int exportedvar;
-              extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
-              extern __attribute__((__visibility__("default"))) int exportedfunc (void);
-              void dummyfunc (void) {}
-            ]],
-            [[]])],
-         [gl_cv_cc_visibility=yes],
-         [gl_cv_cc_visibility=no])
-       CFLAGS="$gl_save_CFLAGS"
-      ])
-    if test $gl_cv_cc_visibility = yes; then
-      CFLAG_VISIBILITY="-fvisibility=hidden"
-      HAVE_VISIBILITY=1
-    fi
-  fi
-  AC_SUBST([CFLAG_VISIBILITY])
-  AC_SUBST([HAVE_VISIBILITY])
-  AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
-    [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
-])
-
 # Copyright (C) 2002-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -1216,4 +1138,5 @@ m4_include([m4/ltoptions.m4])
 m4_include([m4/ltsugar.m4])
 m4_include([m4/ltversion.m4])
 m4_include([m4/lt~obsolete.m4])
+m4_include([m4/visibility.m4])
 m4_include([acinclude.m4])
diff --git a/contrib/file/config.h.in b/contrib/file/config.h.in
index 05dcc8ad6462..ec46e2d8fb99 100644
--- a/contrib/file/config.h.in
+++ b/contrib/file/config.h.in
@@ -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
 
diff --git a/contrib/file/configure b/contrib/file/configure
index 24fd1847b279..d6a18d038f4a 100755
--- a/contrib/file/configure
+++ b/contrib/file/configure
@@ -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.41.
 #
 # 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.41'
+PACKAGE_STRING='file 5.41'
 PACKAGE_BUGREPORT='christos@astron.com'
 PACKAGE_URL=''
 
@@ -1334,7 +1334,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.41 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1404,7 +1404,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.41:";;
    esac
   cat <<\_ACEOF
 
@@ -1524,7 +1524,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-file configure 5.39
+file configure 5.41
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2180,7 +2180,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.41, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3046,7 +3046,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='file'
- VERSION='5.39'
+ VERSION='5.41'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3401,69 +3401,6 @@ fi
 
 
 
-DEPDIR="${am__leading_dot}deps"
-
-ac_config_commands="$ac_config_commands depfiles"
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5
-$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; }
-cat > confinc.mk << 'END'
-am__doit:
-	@echo this is the am__doit target >confinc.out
-.PHONY: am__doit
-END
-am__include="#"
-am__quote=
-# BSD make does it like this.
-echo '.include "confinc.mk" # ignored' > confmf.BSD
-# Other make implementations (GNU, Solaris 10, AIX) do it like this.
-echo 'include confinc.mk # ignored' > confmf.GNU
-_am_result=no
-for s in GNU BSD; do
-  { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5
-   (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5
-   ac_status=$?
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   (exit $ac_status); }
-  case $?:`cat confinc.out 2>/dev/null` in #(
-  '0:this is the am__doit target') :
-    case $s in #(
-  BSD) :
-    am__include='.include' am__quote='"' ;; #(
-  *) :
-    am__include='include' am__quote='' ;;
-esac ;; #(
-  *) :
-     ;;
-esac
-  if test "$am__include" != "#"; then
-    _am_result="yes ($s style)"
-    break
-  fi
-done
-rm -f confinc.* confmf.*
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5
-$as_echo "${_am_result}" >&6; }
-
-# Check whether --enable-dependency-tracking was given.
-if test "${enable_dependency_tracking+set}" = set; then :
-  enableval=$enable_dependency_tracking;
-fi
-
-if test "x$enable_dependency_tracking" != xno; then
-  am_depcomp="$ac_aux_dir/depcomp"
-  AMDEPBACKSLASH='\'
-  am__nodep='_no'
-fi
- if test "x$enable_dependency_tracking" != xno; then
-  AMDEP_TRUE=
-  AMDEP_FALSE='#'
-else
-  AMDEP_TRUE='#'
-  AMDEP_FALSE=
-fi
-
-
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4311,6 +4248,69 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5
+$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; }
+cat > confinc.mk << 'END'
+am__doit:
+	@echo this is the am__doit target >confinc.out
+.PHONY: am__doit
+END
+am__include="#"
+am__quote=
+# BSD make does it like this.
+echo '.include "confinc.mk" # ignored' > confmf.BSD
+# Other make implementations (GNU, Solaris 10, AIX) do it like this.
+echo 'include confinc.mk # ignored' > confmf.GNU
+_am_result=no
+for s in GNU BSD; do
+  { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5
+   (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }
+  case $?:`cat confinc.out 2>/dev/null` in #(
+  '0:this is the am__doit target') :
+    case $s in #(
+  BSD) :
+    am__include='.include' am__quote='"' ;; #(
+  *) :
+    am__include='include' am__quote='' ;;
+esac ;; #(
+  *) :
+     ;;
+esac
+  if test "$am__include" != "#"; then
+    _am_result="yes ($s style)"
+    break
+  fi
+done
+rm -f confinc.* confmf.*
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5
+$as_echo "${_am_result}" >&6; }
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
*** 16159 LINES SKIPPED ***