Virgin import of Christos Zoulas's FILE 3.41.
* - fix memory allocation problem (Jeff Johnson) * - fix stack overflow corruption (David Endler)
This commit is contained in:
parent
3459dd3784
commit
490143648c
12
contrib/file/.cvsignore
Normal file
12
contrib/file/.cvsignore
Normal file
@ -0,0 +1,12 @@
|
||||
Makefile
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
stamp-h
|
||||
file
|
||||
file.1
|
||||
magic.4
|
||||
magic
|
||||
magic.mgc
|
||||
magic.mime.mgc
|
@ -97,6 +97,7 @@
|
||||
>>18 leshort 53 Motorola M68HC12,
|
||||
>>18 leshort 62 AMD x86-64,
|
||||
>>18 leshort 75 Digital VAX,
|
||||
>>18 leshort 97 NatSemi 32k,
|
||||
>>18 leshort 0x9026 Alpha (unofficial),
|
||||
>>20 lelong 0 invalid version
|
||||
>>20 lelong 1 version 1
|
||||
@ -183,6 +184,7 @@
|
||||
>>18 beshort 53 Motorola M68HC12,
|
||||
>>18 beshort 73 Cray NV1,
|
||||
>>18 beshort 75 Digital VAX,
|
||||
>>18 beshort 97 NatSemi 32k,
|
||||
>>18 beshort 0x9026 Alpha (unofficial),
|
||||
>>20 belong 0 invalid version
|
||||
>>20 belong 1 version 1
|
||||
|
@ -167,6 +167,10 @@
|
||||
>8320 lelong 1 SPACE optimization
|
||||
|
||||
9564 belong 0x00011954 Unix Fast File system (big-endian),
|
||||
>7168 long 0x4c41424c Apple UFS Volume
|
||||
>>7186 string x named %s,
|
||||
>>7176 belong x volume label version %d,
|
||||
>>7180 bedate x created on %s,
|
||||
>8404 string x last mounted on %s,
|
||||
#>9504 bedate x last checked at %s,
|
||||
>8224 bedate x last written at %s,
|
||||
|
7
contrib/file/Magdir/hdf
Normal file
7
contrib/file/Magdir/hdf
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Hierarchical Data Format, used to facilitate scientific data exchange
|
||||
# specifications at http://hdf.ncsa.uiuc.edu/
|
||||
|
||||
0 belong 0x0e031301 Hierarchical Data Format (version 4) data
|
||||
0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
|
@ -59,3 +59,6 @@
|
||||
|
||||
# HSI is Handmade Software's proprietary JPEG encoding scheme
|
||||
0 string hsi1 JPEG image data, HSI proprietary
|
||||
|
||||
# From: David Santinoli <david@santinoli.com>
|
||||
0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 image data
|
||||
|
@ -16,6 +16,10 @@
|
||||
0 string Seg StuffIt Deluxe Segment (data)
|
||||
>2 string x : %s
|
||||
|
||||
# Newer StuffIt archives (grant@netbsd.org)
|
||||
0 string StuffIt StuffIt Archive
|
||||
>162 string >0 : %s
|
||||
|
||||
# Macintosh Applications and Installation binaries (franklsm@tuns.ca)
|
||||
0 string APPL Macintosh Application (data)
|
||||
>2 string x \b: %s
|
||||
|
18
contrib/file/Magdir/sql
Normal file
18
contrib/file/Magdir/sql
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# sql: file(1) magic for SQL files
|
||||
#
|
||||
# From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
|
||||
# Recognize some MySQL files.
|
||||
#
|
||||
0 beshort 0xfe01 MySQL table definition file
|
||||
>2 byte x Version %d
|
||||
0 belong&0xffffff00 0xfefe0300 MySQL MISAM index file
|
||||
>3 byte x Version %d
|
||||
0 belong&0xffffff00 0xfefe0700 MySQL MISAM compressed data file
|
||||
>3 byte x Version %d
|
||||
0 belong&0xffffff00 0xfefe0500 MySQL ISAM index file
|
||||
>3 byte x Version %d
|
||||
0 belong&0xffffff00 0xfefe0600 MySQL ISAM compressed data file
|
||||
>3 byte x Version %d
|
||||
0 string \376bin MySQL replication log
|
@ -110,6 +110,7 @@ Magdir/gimp \
|
||||
Magdir/gnu \
|
||||
Magdir/grace \
|
||||
Magdir/gringotts \
|
||||
Magdir/hdf \
|
||||
Magdir/hitachi-sh \
|
||||
Magdir/hp \
|
||||
Magdir/ibm370 \
|
||||
@ -185,6 +186,7 @@ Magdir/smalltalk \
|
||||
Magdir/sniffer \
|
||||
Magdir/softquad \
|
||||
Magdir/spectrum \
|
||||
Magdir/sql \
|
||||
Magdir/sun \
|
||||
Magdir/sysex \
|
||||
Magdir/teapot \
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
@ -73,20 +73,179 @@ data_DATA = magic magic.mime magic.mgc magic.mime.mgc
|
||||
|
||||
MAGIC = @datadir@/magic
|
||||
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
|
||||
@FSECT5_TRUE@man_MAGIC = magic.5
|
||||
@FSECT5_FALSE@man_MAGIC = magic.4
|
||||
@FSECT5_TRUE@man_MAGIC = @FSECT5_TRUE@magic.5
|
||||
@FSECT5_FALSE@man_MAGIC = @FSECT5_FALSE@magic.4
|
||||
fsect = @fsect@
|
||||
man_MANS = file.1 $(man_MAGIC)
|
||||
|
||||
file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c compress.c is_tar.c readelf.c print.c file.h names.h patchlevel.h readelf.h tar.h
|
||||
file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
|
||||
compress.c is_tar.c readelf.c print.c \
|
||||
file.h names.h patchlevel.h readelf.h tar.h
|
||||
|
||||
|
||||
EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime Localstuff Header $(magic_FRAGMENTS) file.man magic.man
|
||||
EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime \
|
||||
Localstuff Header $(magic_FRAGMENTS) file.man magic.man
|
||||
|
||||
|
||||
CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
|
||||
|
||||
magic_FRAGMENTS = Magdir/acorn Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi Magdir/c-lang Magdir/cddb Magdir/chi Magdir/cisco Magdir/citrus Magdir/claris Magdir/clipper Magdir/commands Magdir/compress Magdir/console Magdir/convex Magdir/ctags Magdir/cvs Magdir/database Magdir/diamond Magdir/diff Magdir/digital Magdir/dolby Magdir/dump Magdir/dyadic Magdir/editors Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav Magdir/gimp Magdir/gnu Magdir/grace Magdir/gringotts Magdir/hitachi-sh Magdir/hp Magdir/ibm370 Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel Magdir/interleaf Magdir/island Magdir/ispell Magdir/java Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/mlssa Magdir/modem Magdir/motorola Magdir/msdos Magdir/msvc Magdir/natinst Magdir/ncr Magdir/netbsd Magdir/netscape Magdir/news Magdir/nitpicker Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 Magdir/osf1 Magdir/palm Magdir/parix Magdir/pbm Magdir/pdf Magdir/pdp Magdir/perl Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project Magdir/psdbms Magdir/pulsar Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent Magdir/sgml Magdir/sharc Magdir/sketch Magdir/smalltalk Magdir/sniffer Magdir/softquad Magdir/spectrum Magdir/sun Magdir/sysex Magdir/teapot Magdir/terminfo Magdir/tex Magdir/tgif Magdir/ti-8x Magdir/timezone Magdir/troff Magdir/tuxedo Magdir/typeset Magdir/unknown Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx Magdir/vms Magdir/vmware Magdir/vorbis Magdir/vxl Magdir/wordperfect Magdir/xdelta Magdir/xenix Magdir/zilog Magdir/zyxel
|
||||
magic_FRAGMENTS = \
|
||||
Magdir/acorn \
|
||||
Magdir/adi \
|
||||
Magdir/adventure \
|
||||
Magdir/allegro \
|
||||
Magdir/alliant \
|
||||
Magdir/alpha \
|
||||
Magdir/amanda \
|
||||
Magdir/amigaos \
|
||||
Magdir/animation \
|
||||
Magdir/apl \
|
||||
Magdir/apple \
|
||||
Magdir/applix \
|
||||
Magdir/archive \
|
||||
Magdir/asterix \
|
||||
Magdir/att3b \
|
||||
Magdir/audio \
|
||||
Magdir/blender \
|
||||
Magdir/blit \
|
||||
Magdir/bsdi \
|
||||
Magdir/c-lang \
|
||||
Magdir/cddb \
|
||||
Magdir/chi \
|
||||
Magdir/cisco \
|
||||
Magdir/citrus \
|
||||
Magdir/claris \
|
||||
Magdir/clipper \
|
||||
Magdir/commands \
|
||||
Magdir/compress \
|
||||
Magdir/console \
|
||||
Magdir/convex \
|
||||
Magdir/ctags \
|
||||
Magdir/cvs \
|
||||
Magdir/database \
|
||||
Magdir/diamond \
|
||||
Magdir/diff \
|
||||
Magdir/digital \
|
||||
Magdir/dolby \
|
||||
Magdir/dump \
|
||||
Magdir/dyadic \
|
||||
Magdir/editors \
|
||||
Magdir/elf \
|
||||
Magdir/encore \
|
||||
Magdir/epoc \
|
||||
Magdir/filesystems \
|
||||
Magdir/flash \
|
||||
Magdir/fonts \
|
||||
Magdir/frame \
|
||||
Magdir/freebsd \
|
||||
Magdir/fsav \
|
||||
Magdir/gimp \
|
||||
Magdir/gnu \
|
||||
Magdir/grace \
|
||||
Magdir/gringotts \
|
||||
Magdir/hdf \
|
||||
Magdir/hitachi-sh \
|
||||
Magdir/hp \
|
||||
Magdir/ibm370 \
|
||||
Magdir/ibm6000 \
|
||||
Magdir/iff \
|
||||
Magdir/images \
|
||||
Magdir/intel \
|
||||
Magdir/interleaf \
|
||||
Magdir/island \
|
||||
Magdir/ispell \
|
||||
Magdir/java \
|
||||
Magdir/jpeg \
|
||||
Magdir/karma \
|
||||
Magdir/lecter \
|
||||
Magdir/lex \
|
||||
Magdir/lif \
|
||||
Magdir/linux \
|
||||
Magdir/lisp \
|
||||
Magdir/mach \
|
||||
Magdir/macintosh \
|
||||
Magdir/magic \
|
||||
Magdir/mail.news \
|
||||
Magdir/maple \
|
||||
Magdir/mathematica \
|
||||
Magdir/mcrypt \
|
||||
Magdir/mime \
|
||||
Magdir/mips \
|
||||
Magdir/mirage \
|
||||
Magdir/mkid \
|
||||
Magdir/mmdf \
|
||||
Magdir/mlssa \
|
||||
Magdir/modem \
|
||||
Magdir/motorola \
|
||||
Magdir/msdos \
|
||||
Magdir/msvc \
|
||||
Magdir/natinst \
|
||||
Magdir/ncr \
|
||||
Magdir/netbsd \
|
||||
Magdir/netscape \
|
||||
Magdir/news \
|
||||
Magdir/nitpicker \
|
||||
Magdir/octave \
|
||||
Magdir/olf \
|
||||
Magdir/os2 \
|
||||
Magdir/os9 \
|
||||
Magdir/osf1 \
|
||||
Magdir/palm \
|
||||
Magdir/parix \
|
||||
Magdir/pbm \
|
||||
Magdir/pdf \
|
||||
Magdir/pdp \
|
||||
Magdir/perl \
|
||||
Magdir/pgp \
|
||||
Magdir/pkgadd \
|
||||
Magdir/plus5 \
|
||||
Magdir/printer \
|
||||
Magdir/project \
|
||||
Magdir/psdbms \
|
||||
Magdir/pulsar \
|
||||
Magdir/pyramid \
|
||||
Magdir/python \
|
||||
Magdir/riff \
|
||||
Magdir/rpm \
|
||||
Magdir/rtf \
|
||||
Magdir/sc \
|
||||
Magdir/sccs \
|
||||
Magdir/sendmail \
|
||||
Magdir/sequent \
|
||||
Magdir/sgml \
|
||||
Magdir/sharc \
|
||||
Magdir/sketch \
|
||||
Magdir/smalltalk \
|
||||
Magdir/sniffer \
|
||||
Magdir/softquad \
|
||||
Magdir/spectrum \
|
||||
Magdir/sql \
|
||||
Magdir/sun \
|
||||
Magdir/sysex \
|
||||
Magdir/teapot \
|
||||
Magdir/terminfo \
|
||||
Magdir/tex \
|
||||
Magdir/tgif \
|
||||
Magdir/ti-8x \
|
||||
Magdir/timezone \
|
||||
Magdir/troff \
|
||||
Magdir/tuxedo \
|
||||
Magdir/typeset \
|
||||
Magdir/unknown \
|
||||
Magdir/uuencode \
|
||||
Magdir/varied.out \
|
||||
Magdir/vax \
|
||||
Magdir/vicar \
|
||||
Magdir/visx \
|
||||
Magdir/vms \
|
||||
Magdir/vmware \
|
||||
Magdir/vorbis \
|
||||
Magdir/vxl \
|
||||
Magdir/wordperfect \
|
||||
Magdir/xdelta \
|
||||
Magdir/xenix \
|
||||
Magdir/zilog \
|
||||
Magdir/zyxel
|
||||
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
@ -122,7 +281,7 @@ missing mkinstalldirs
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(file_SOURCES)
|
||||
OBJECTS = $(file_OBJECTS)
|
||||
@ -416,7 +575,7 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Makefile for file(1) cmd.
|
||||
# Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
|
||||
# @(#)$Id: Makefile.std,v 1.16 2003/02/08 18:35:36 christos Exp $
|
||||
# @(#)$Id: Makefile.std,v 1.17 2003/02/27 20:47:45 christos Exp $
|
||||
#
|
||||
# This software is not subject to any license of the American Telephone
|
||||
# and Telegraph Company or of the Regents of the University of California.
|
||||
@ -22,7 +22,7 @@
|
||||
#
|
||||
# 4. This notice may not be removed or altered.
|
||||
#
|
||||
VERSION = 3.40
|
||||
VERSION = 3.41
|
||||
SHELL = /bin/sh
|
||||
#MAGIC = /etc/magic
|
||||
MAGIC = /usr/local/etc/magic
|
||||
|
@ -1,5 +1,5 @@
|
||||
** README for file(1) Command **
|
||||
@(#) $Id: README,v 1.28 2003/02/08 18:35:36 christos Exp $
|
||||
@(#) $Id: README,v 1.29 2003/02/27 20:47:46 christos Exp $
|
||||
|
||||
This is Release 3.x of Ian Darwin's (copyright but distributable)
|
||||
file(1) command. This version is the standard "file" command for Linux,
|
||||
@ -91,7 +91,7 @@ DOS and Mac.
|
||||
|
||||
From: Kees Zeelenberg
|
||||
|
||||
An MS-Windows (Win32) port of File-3.40 is available from
|
||||
An MS-Windows (Win32) port of File-3.41 is available from
|
||||
http://gnuwin32.sourceforge.net/
|
||||
File is an implementation of the Unix File(1) command.
|
||||
It knows the 'magic number' of several thousands of file types.
|
||||
|
@ -41,6 +41,9 @@
|
||||
standard headers don't define. */
|
||||
#undef uint64_t
|
||||
|
||||
/* Define to `int' if standard headers don't define. */
|
||||
#undef int32_t
|
||||
|
||||
/* FIXME: These have to be added manually because autoheader doesn't know
|
||||
about AC_CHECK_SIZEOF_INCLUDES. */
|
||||
|
||||
|
14
contrib/file/aclocal.m4
vendored
14
contrib/file/aclocal.m4
vendored
@ -1,6 +1,6 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4-p5
|
||||
|
||||
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 1994, 1995-8, 1999, 2001 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.
|
||||
@ -274,7 +274,7 @@ AC_DEFUN([AC_FUNC_FSEEKO],
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
@ -302,7 +302,7 @@ AC_REQUIRE([AC_PROG_MAKE_SET])])
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
AC_DEFUN([AM_SANITY_CHECK],
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
@ -343,7 +343,7 @@ AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
AC_DEFUN([AM_MISSING_PROG],
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
@ -359,7 +359,7 @@ AC_SUBST($1)])
|
||||
|
||||
# Like AC_CONFIG_HEADER, but automatically create stamp file.
|
||||
|
||||
AC_DEFUN(AM_CONFIG_HEADER,
|
||||
AC_DEFUN([AM_CONFIG_HEADER],
|
||||
[AC_PREREQ([2.12])
|
||||
AC_CONFIG_HEADER([$1])
|
||||
dnl When config.status generates a header, we must update the stamp-h file.
|
||||
@ -382,7 +382,7 @@ changequote([,]))])
|
||||
|
||||
# Define a conditional.
|
||||
|
||||
AC_DEFUN(AM_CONDITIONAL,
|
||||
AC_DEFUN([AM_CONDITIONAL],
|
||||
[AC_SUBST($1_TRUE)
|
||||
AC_SUBST($1_FALSE)
|
||||
if $2; then
|
||||
|
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: apprentice.c,v 1.49 2002/07/03 19:00:41 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: apprentice.c,v 1.50 2003/02/27 20:47:46 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#define EATAB {while (isascii((unsigned char) *l) && \
|
||||
@ -231,7 +231,7 @@ apprentice_file(struct magic **magicp, uint32_t *nmagicp, const char *fn,
|
||||
}
|
||||
|
||||
maxmagic = MAXMAGIS;
|
||||
*magicp = (struct magic *) calloc(sizeof(struct magic), maxmagic);
|
||||
*magicp = (struct magic *) calloc(maxmagic, sizeof(struct magic));
|
||||
if (*magicp == NULL) {
|
||||
(void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
|
||||
strerror(errno));
|
||||
|
@ -55,6 +55,9 @@
|
||||
standard headers don't define. */
|
||||
#undef uint64_t
|
||||
|
||||
/* Define to `int' if standard headers don't define. */
|
||||
#undef int32_t
|
||||
|
||||
/* The number of bytes in a uint8_t. */
|
||||
#define SIZEOF_UINT8_T 0
|
||||
|
||||
|
92
contrib/file/configure
vendored
92
contrib/file/configure
vendored
@ -699,7 +699,7 @@ fi
|
||||
|
||||
PACKAGE=file
|
||||
|
||||
VERSION=3.40
|
||||
VERSION=3.41
|
||||
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
|
||||
@ -1628,7 +1628,7 @@ else
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_hdr in unistd.h
|
||||
for ac_hdr in stdint.h inttypes.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
@ -1668,7 +1668,7 @@ else
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_hdr in getopt.h
|
||||
for ac_hdr in unistd.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
@ -1708,7 +1708,7 @@ else
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_hdr in locale.h
|
||||
for ac_hdr in getopt.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
@ -1748,7 +1748,7 @@ else
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_hdr in stdint.h
|
||||
for ac_hdr in locale.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
@ -2462,8 +2462,44 @@ EOF
|
||||
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for int32_t""... $ac_c" 1>&6
|
||||
echo "configure:2467: checking for int32_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_int32_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2472 "configure"
|
||||
#include "confdefs.h"
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
EOF
|
||||
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
|
||||
egrep "(^|[^a-zA-Z_0-9])int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
|
||||
rm -rf conftest*
|
||||
ac_cv_type_int32_t=yes
|
||||
else
|
||||
rm -rf conftest*
|
||||
ac_cv_type_int32_t=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
|
||||
fi
|
||||
echo "$ac_t""$ac_cv_type_int32_t" 1>&6
|
||||
if test $ac_cv_type_int32_t = no; then
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define int32_t int
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for long long""... $ac_c" 1>&6
|
||||
echo "configure:2467: checking for long long" >&5
|
||||
echo "configure:2503: checking for long long" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_c_long_long'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -2474,13 +2510,13 @@ if test "$cross_compiling" = yes; then
|
||||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2478 "configure"
|
||||
#line 2514 "configure"
|
||||
#include "confdefs.h"
|
||||
int main() {
|
||||
long long foo = 0;
|
||||
exit(sizeof(long long) < sizeof(long)); }
|
||||
EOF
|
||||
if { (eval echo configure:2484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:2520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_c_long_long=yes
|
||||
else
|
||||
@ -2509,12 +2545,12 @@ else
|
||||
long64='unsigned long';
|
||||
fi
|
||||
echo $ac_n "checking for uint64_t""... $ac_c" 1>&6
|
||||
echo "configure:2513: checking for uint64_t" >&5
|
||||
echo "configure:2549: checking for uint64_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_uint64_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2518 "configure"
|
||||
#line 2554 "configure"
|
||||
#include "confdefs.h"
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@ -2548,7 +2584,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking size of uint8_t""... $ac_c" 1>&6
|
||||
echo "configure:2552: checking size of uint8_t" >&5
|
||||
echo "configure:2588: checking size of uint8_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_uint8_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -2556,7 +2592,7 @@ else
|
||||
ac_cv_sizeof_uint8_t=0
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2560 "configure"
|
||||
#line 2596 "configure"
|
||||
#include "confdefs.h"
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@ -2575,7 +2611,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:2579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:2615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_uint8_t=`cat conftestval`
|
||||
else
|
||||
@ -2596,7 +2632,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of uint16_t""... $ac_c" 1>&6
|
||||
echo "configure:2600: checking size of uint16_t" >&5
|
||||
echo "configure:2636: checking size of uint16_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_uint16_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -2604,7 +2640,7 @@ else
|
||||
ac_cv_sizeof_uint16_t=0
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2608 "configure"
|
||||
#line 2644 "configure"
|
||||
#include "confdefs.h"
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@ -2623,7 +2659,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:2627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:2663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_uint16_t=`cat conftestval`
|
||||
else
|
||||
@ -2644,7 +2680,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of uint32_t""... $ac_c" 1>&6
|
||||
echo "configure:2648: checking size of uint32_t" >&5
|
||||
echo "configure:2684: checking size of uint32_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_uint32_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -2652,7 +2688,7 @@ else
|
||||
ac_cv_sizeof_uint32_t=0
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2656 "configure"
|
||||
#line 2692 "configure"
|
||||
#include "confdefs.h"
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@ -2671,7 +2707,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:2675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:2711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_uint32_t=`cat conftestval`
|
||||
else
|
||||
@ -2692,7 +2728,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of uint64_t""... $ac_c" 1>&6
|
||||
echo "configure:2696: checking size of uint64_t" >&5
|
||||
echo "configure:2732: checking size of uint64_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_uint64_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -2700,7 +2736,7 @@ else
|
||||
ac_cv_sizeof_uint64_t=0
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2704 "configure"
|
||||
#line 2740 "configure"
|
||||
#include "confdefs.h"
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@ -2719,7 +2755,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:2759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_uint64_t=`cat conftestval`
|
||||
else
|
||||
@ -2743,12 +2779,12 @@ EOF
|
||||
for ac_func in mmap strerror strtoul mkstemp getopt_long
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:2747: checking for $ac_func" >&5
|
||||
echo "configure:2783: checking for $ac_func" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2752 "configure"
|
||||
#line 2788 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -2771,7 +2807,7 @@ $ac_func();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:2775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:2811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -2797,7 +2833,7 @@ done
|
||||
|
||||
|
||||
echo $ac_n "checking for gzopen in -lz""... $ac_c" 1>&6
|
||||
echo "configure:2801: checking for gzopen in -lz" >&5
|
||||
echo "configure:2837: checking for gzopen in -lz" >&5
|
||||
ac_lib_var=`echo z'_'gzopen | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@ -2805,7 +2841,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lz $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2809 "configure"
|
||||
#line 2845 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@ -2816,7 +2852,7 @@ int main() {
|
||||
gzopen()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:2820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:2856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
|
@ -1,6 +1,6 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(file.c)
|
||||
AM_INIT_AUTOMAKE(file, 3.39)
|
||||
AM_INIT_AUTOMAKE(file, 3.41)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_MSG_CHECKING(for builtin ELF support)
|
||||
@ -76,6 +76,7 @@ AC_SYS_LARGEFILE
|
||||
AC_CHECK_TYPE_STDC(uint8_t, unsigned char)
|
||||
AC_CHECK_TYPE_STDC(uint16_t, unsigned short)
|
||||
AC_CHECK_TYPE_STDC(uint32_t, unsigned int)
|
||||
AC_CHECK_TYPE_STDC(int32_t, int)
|
||||
AC_C_LONG_LONG
|
||||
if test $ac_cv_c_long_long = yes; then
|
||||
long64='unsigned long long';
|
||||
|
@ -58,7 +58,7 @@
|
||||
#include "patchlevel.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: file.c,v 1.68 2003/02/08 18:33:53 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: file.c,v 1.69 2003/02/27 20:47:46 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
|
||||
@ -429,7 +429,7 @@ process(const char *inname, int wid)
|
||||
|
||||
if ((fd = open(inname, O_RDONLY)) < 0) {
|
||||
/* We can't open it, but we were able to stat it. */
|
||||
if (sb.st_mode & 0002) ckfputs("writeable, ", stdout);
|
||||
if (sb.st_mode & 0002) ckfputs("writable, ", stdout);
|
||||
if (sb.st_mode & 0111) ckfputs("executable, ", stdout);
|
||||
ckfprintf(stdout, "can't read `%s' (%s).\n",
|
||||
inname, strerror(errno));
|
||||
|
@ -1,5 +1,5 @@
|
||||
.TH FILE __CSECTION__ "Copyright but distributable"
|
||||
.\" $Id: file.man,v 1.43 2003/02/08 18:33:53 christos Exp $
|
||||
.\" $Id: file.man,v 1.44 2003/02/27 20:47:46 christos Exp $
|
||||
.SH NAME
|
||||
file
|
||||
\- determine file type
|
||||
@ -180,10 +180,12 @@ Use the specified separator character instead of ``:''.
|
||||
.TP 8
|
||||
.B \-i
|
||||
Causes the file command to output mime type strings rather than the more
|
||||
traditional human readable ones. Thus it may say
|
||||
traditional human readable ones.
|
||||
Thus it may say
|
||||
``text/plain; charset=us-ascii''
|
||||
rather
|
||||
than ``ASCII text''. In order for this option to work, file changes the way
|
||||
than ``ASCII text''.
|
||||
In order for this option to work, file changes the way
|
||||
it handles files recognised by the command itself (such as many of the
|
||||
text file types, directories etc), and makes use of an alternative
|
||||
``magic'' file.
|
||||
@ -197,9 +199,9 @@ Specify an alternate list of files containing magic numbers.
|
||||
This can be a single file, or a colon-separated list of files.
|
||||
.TP 8
|
||||
.B \-n
|
||||
Force stdout to be flushed after checking each file. This is only useful if
|
||||
checking a list of files. It is intended to be used by programs that want
|
||||
filetype output from a pipe.
|
||||
Force stdout to be flushed after checking each file.
|
||||
This is only useful if checking a list of files.
|
||||
It is intended to be used by programs that want filetype output from a pipe.
|
||||
.TP 8
|
||||
.B \-N
|
||||
Don't pad output to align filenames nicely.
|
||||
@ -322,7 +324,7 @@ file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
|
||||
$ file -s /dev/wd0{b,d}
|
||||
/dev/wd0b: data
|
||||
/dev/wd0d: x86 boot sector
|
||||
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
|
||||
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} # Linux
|
||||
/dev/hda: x86 boot sector
|
||||
/dev/hda1: Linux/i386 ext2 filesystem
|
||||
/dev/hda2: x86 boot sector
|
||||
@ -335,6 +337,22 @@ $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
|
||||
/dev/hda9: empty
|
||||
/dev/hda10: empty
|
||||
|
||||
$ file -s /dev/rwd0e # BSD
|
||||
/dev/rwd0e:
|
||||
Unix Fast File system (little-endian),
|
||||
last mounted on /usr,
|
||||
last written at Mon Feb 10 13:22:40 2003,
|
||||
clean flag 2,
|
||||
number of blocks 28754208,
|
||||
number of data blocks 27812712,
|
||||
number of cylinder groups 3566,
|
||||
block size 8192,
|
||||
fragment size 1024,
|
||||
minimum percentage of free blocks 5,
|
||||
rotational delay 0ms,
|
||||
disk rotational speed 60rps,
|
||||
TIME optimization
|
||||
|
||||
$ file -i file.c file /dev/{wd0a,hda}
|
||||
file.c: text/x-c
|
||||
file: application/x-executable, dynamically linked (uses shared libs),
|
||||
@ -377,7 +395,8 @@ of non-ASCII files.
|
||||
.PP
|
||||
The list of contributors to the "Magdir" directory (source for the
|
||||
/etc/magic
|
||||
file) is too long to include here. You know who you are; thank you.
|
||||
file) is too long to include here.
|
||||
You know who you are; thank you.
|
||||
.SH LEGAL NOTICE
|
||||
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
|
||||
Covered by the standard Berkeley Software Distribution copyright; see the file
|
||||
@ -392,7 +411,8 @@ were written by John Gilmore from his public-domain
|
||||
program, and are not covered by the above license.
|
||||
.SH BUGS
|
||||
There must be a better way to automate the construction of the Magic
|
||||
file from all the glop in Magdir. What is it?
|
||||
file from all the glop in Magdir.
|
||||
What is it?
|
||||
Better yet, the magic file should be compiled into binary (say,
|
||||
.BR ndbm (3)
|
||||
or, better yet, fixed-length
|
||||
@ -439,7 +459,8 @@ This could be done by using some keyword like `*' for the offset value.
|
||||
Another optimisation would be to sort
|
||||
the magic file so that we can just run down all the
|
||||
tests for the first byte, first word, first long, etc, once we
|
||||
have fetched it. Complain about conflicts in the magic file entries.
|
||||
have fetched it.
|
||||
Complain about conflicts in the magic file entries.
|
||||
Make a rule that the magic entries sort based on file offset rather
|
||||
than position within the magic file?
|
||||
.PP
|
||||
@ -447,7 +468,8 @@ The program should provide a way to give an estimate
|
||||
of ``how good'' a guess is.
|
||||
We end up removing guesses (e.g. ``From '' as first 5 chars of file) because
|
||||
they are not as good as other guesses (e.g. ``Newsgroups:'' versus
|
||||
``Return-Path:''). Still, if the others don't pan out, it should be
|
||||
``Return-Path:'').
|
||||
Still, if the others don't pan out, it should be
|
||||
possible to use the first guess.
|
||||
.PP
|
||||
This program is slower than some vendors' file commands.
|
||||
@ -459,4 +481,4 @@ You can obtain the original author's latest version by anonymous FTP
|
||||
on
|
||||
.B ftp.astron.com
|
||||
in the directory
|
||||
.I /pub/file/file-X.YY.tar.gz
|
||||
.I /pub/file/file-X.YZ.tar.gz
|
||||
|
@ -6,7 +6,8 @@ magic \- file command's magic number file
|
||||
This manual page documents the format of the magic file as
|
||||
used by the
|
||||
.BR file (__CSECTION__)
|
||||
command, version __VERSION__. The
|
||||
command, version __VERSION__.
|
||||
The
|
||||
.BR file
|
||||
command identifies the type of a file using,
|
||||
among other tests,
|
||||
@ -21,13 +22,15 @@ and additional information to extract from the file.
|
||||
Each line of the file specifies a test to be performed.
|
||||
A test compares the data starting at a particular offset
|
||||
in the file with a 1-byte, 2-byte, or 4-byte numeric value or
|
||||
a string. If the test succeeds, a message is printed.
|
||||
a string.
|
||||
If the test succeeds, a message is printed.
|
||||
The line consists of the following fields:
|
||||
.IP offset \w'message'u+2n
|
||||
A number specifying the offset, in bytes, into the file of the data
|
||||
which is to be tested.
|
||||
.IP type
|
||||
The type of the data to be tested. The possible values are:
|
||||
The type of the data to be tested.
|
||||
The possible values are:
|
||||
.RS
|
||||
.IP byte \w'message'u+2n
|
||||
A one-byte value.
|
||||
@ -36,11 +39,14 @@ A two-byte value (on most systems) in this machine's native byte order.
|
||||
.IP long
|
||||
A four-byte value (on most systems) in this machine's native byte order.
|
||||
.IP string
|
||||
A string of bytes. The string type specification can be optionally followed
|
||||
by /[Bbc]*. The ``B'' flag compacts whitespace in the target, which must
|
||||
contain at least one whitespace character. If the magic has "n" consecutive
|
||||
blanks, the target needs at least "n" consecutive blanks to match. The ``b''
|
||||
flag treats every blank in the target as an optional blank. Finally the ``c''
|
||||
A string of bytes.
|
||||
The string type specification can be optionally followed by /[Bbc]*.
|
||||
The ``B'' flag compacts whitespace in the target, which must
|
||||
contain at least one whitespace character.
|
||||
If the magic has "n" consecutive
|
||||
blanks, the target needs at least "n" consecutive blanks to match.
|
||||
The ``b'' flag treats every blank in the target as an optional blank.
|
||||
Finally the ``c''
|
||||
flag, specifies case insensitive matching: lowercase characters in the magic
|
||||
match both lower and upper case characters in the targer, whereas upper case
|
||||
characters in the magic, only much uppercase characters in the target.
|
||||
@ -73,12 +79,13 @@ The numeric types may optionally be followed by
|
||||
.B \*[Am]
|
||||
and a numeric value,
|
||||
to specify that the value is to be AND'ed with the
|
||||
numeric value before any comparisons are done. Prepending a
|
||||
numeric value before any comparisons are done.
|
||||
Prepending a
|
||||
.B u
|
||||
to the type indicates that ordered comparisons should be unsigned.
|
||||
.IP test
|
||||
The value to be compared with the value from the file. If the type is
|
||||
numeric, this value
|
||||
The value to be compared with the value from the file.
|
||||
If the type is numeric, this value
|
||||
is specified in C form; if it is a string, it is specified as a C string
|
||||
with the usual escapes permitted (e.g. \en for new-line).
|
||||
.IP
|
||||
@ -100,8 +107,8 @@ that are set in the specified value,
|
||||
to specify that the value from the file must have clear any of the bits
|
||||
that are set in the specified value, or
|
||||
.BR x ,
|
||||
to specify that any value will match. If the character is omitted,
|
||||
it is assumed to be
|
||||
to specify that any value will match.
|
||||
If the character is omitted, it is assumed to be
|
||||
.BR = .
|
||||
.IP
|
||||
Numeric values are specified in C form; e.g.
|
||||
@ -123,21 +130,24 @@ and
|
||||
.BR \*[Am] )
|
||||
can be applied to strings.
|
||||
The length used for matching is that of the string argument
|
||||
in the magic file. This means that a line can match any string, and
|
||||
in the magic file.
|
||||
This means that a line can match any string, and
|
||||
then presumably print that string, by doing
|
||||
.B \*[Gt]\e0
|
||||
(because all strings are greater than the null string).
|
||||
.IP message
|
||||
The message to be printed if the comparison succeeds. If the string
|
||||
contains a
|
||||
The message to be printed if the comparison succeeds.
|
||||
If the string contains a
|
||||
.BR printf (3)
|
||||
format specification, the value from the file (with any specified masking
|
||||
performed) is printed using the message as the format string.
|
||||
.PP
|
||||
Some file formats contain additional information which is to be printed
|
||||
along with the file type. A line which begins with the character
|
||||
along with the file type.
|
||||
A line which begins with the character
|
||||
.B \*[Gt]
|
||||
indicates additional tests and messages to be printed. The number of
|
||||
indicates additional tests and messages to be printed.
|
||||
The number of
|
||||
.B \*[Gt]
|
||||
on the line indicates the level of the test; a line with no
|
||||
.B \*[Gt]
|
||||
@ -151,8 +161,8 @@ If the test on a line at level
|
||||
.I n
|
||||
succeeds, the tests specified in all the subsequent lines at level
|
||||
.IB n \(pl1
|
||||
are performed, and the messages printed if the tests succeed. The next
|
||||
line at level
|
||||
are performed, and the messages printed if the tests succeed.
|
||||
The next line at level
|
||||
.I n
|
||||
terminates this.
|
||||
If the first character following the last
|
||||
@ -161,27 +171,33 @@ is a
|
||||
.B (
|
||||
then the string after the parenthesis is interpreted as an indirect offset.
|
||||
That means that the number after the parenthesis is used as an offset in
|
||||
the file. The value at that offset is read, and is used again as an offset
|
||||
in the file. Indirect offsets are of the form:
|
||||
the file.
|
||||
The value at that offset is read, and is used again as an offset
|
||||
in the file.
|
||||
Indirect offsets are of the form:
|
||||
.BI (( x [.[bslBSL]][+-][ y ]).
|
||||
The value of
|
||||
.I x
|
||||
is used as an offset in the file. A byte, short or long is read at that offset
|
||||
depending on the
|
||||
is used as an offset in the file.
|
||||
A byte, short or long is read at that offset depending on the
|
||||
.B [bslBSL]
|
||||
type specifier. The capitalized types interpret the number as a big endian
|
||||
type specifier.
|
||||
The capitalized types interpret the number as a big endian
|
||||
value, whereas the small letter versions interpret the number as a little
|
||||
endian value. To that number the value of
|
||||
endian value.
|
||||
To that number the value of
|
||||
.I y
|
||||
is added and the result is used as an offset in the file. The default type
|
||||
if one is not specified is long.
|
||||
is added and the result is used as an offset in the file.
|
||||
The default type if one is not specified is long.
|
||||
.PP
|
||||
Sometimes you do not know the exact offset as this depends on the length of
|
||||
preceding fields. You can specify an offset relative to the end of the
|
||||
preceding fields.
|
||||
You can specify an offset relative to the end of the
|
||||
last uplevel field (of course this may only be done for sublevel tests, i.e.
|
||||
test beginning with
|
||||
.B \*[Gt]
|
||||
). Such a relative offset is specified using
|
||||
).
|
||||
Such a relative offset is specified using
|
||||
.B \*[Am]
|
||||
as a prefix to the offset.
|
||||
.SH BUGS
|
||||
@ -219,4 +235,4 @@ indirect offsets.
|
||||
.\" the changes I posted to the S5R2 version.
|
||||
.\"
|
||||
.\" Modified for Ian Darwin's version of the file command.
|
||||
.\" @(#)$Id: magic.man,v 1.20 2003/02/08 18:33:53 christos Exp $
|
||||
.\" @(#)$Id: magic.man,v 1.21 2003/02/27 20:47:46 christos Exp $
|
||||
|
@ -86,9 +86,9 @@
|
||||
# Microsoft WAVE format (*.wav)
|
||||
# [GRR 950115: probably all of the shorts and longs should be leshort/lelong]
|
||||
# Microsoft RIFF
|
||||
0 string RIFF audio/unknown
|
||||
0 string RIFF
|
||||
# - WAVE format
|
||||
>8 string WAVE audio/x-wav
|
||||
>8 string WAVE audio/x-wav
|
||||
>8 string AVI video/x-msvideo
|
||||
#
|
||||
0 belong 0x2e7261fd application/x-realaudio
|
||||
@ -543,3 +543,9 @@
|
||||
|
||||
# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
|
||||
0 string \x8aMNG video/x-mng
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Hierarchical Data Format, used to facilitate scientific data exchange
|
||||
# specifications at http://hdf.ncsa.uiuc.edu/
|
||||
0 belong 0x0e031301 Hierarchical Data Format (version 4) data
|
||||
0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
|
||||
|
@ -1,11 +1,17 @@
|
||||
#define FILE_VERSION_MAJOR 3
|
||||
#define patchlevel 40
|
||||
#define patchlevel 41
|
||||
|
||||
/*
|
||||
* Patchlevel file for Ian Darwin's MAGIC command.
|
||||
* $Id: patchlevel.h,v 1.40 2003/02/08 18:33:53 christos Exp $
|
||||
* $Id: patchlevel.h,v 1.41 2003/02/27 20:53:45 christos Exp $
|
||||
*
|
||||
* $Log: patchlevel.h,v $
|
||||
* Revision 1.41 2003/02/27 20:53:45 christos
|
||||
* - fix memory allocation problem (Jeff Johnson)
|
||||
* - fix stack overflow corruption (David Endler)
|
||||
* - fixes from NetBSD source (Antti Kantee)
|
||||
* - magic fixes
|
||||
*
|
||||
* Revision 1.40 2003/02/08 18:33:53 christos
|
||||
* - detect inttypes.h too (Dave Love <d.love@dl.ac.uk>)
|
||||
* - eliminate unsigned char warnings (Petter Reinholdtsen <pere@hungry.com>)
|
||||
@ -238,4 +244,3 @@
|
||||
* Fix a tiny null-pointer bug in previous fix for tar archive + uncompress.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "readelf.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: readelf.c,v 1.23 2003/02/08 18:33:53 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: readelf.c,v 1.26 2003/02/25 15:30:00 christos Exp $")
|
||||
#endif
|
||||
|
||||
#ifdef ELFCORE
|
||||
@ -92,12 +92,18 @@ getu64(int swap, uint64_t value)
|
||||
#define sh_addr (class == ELFCLASS32 \
|
||||
? (void *) &sh32 \
|
||||
: (void *) &sh64)
|
||||
#define sh_size (class == ELFCLASS32 \
|
||||
? sizeof sh32 \
|
||||
: sizeof sh64)
|
||||
#define shs_type (class == ELFCLASS32 \
|
||||
? getu32(swap, sh32.sh_type) \
|
||||
: getu32(swap, sh64.sh_type))
|
||||
#define ph_addr (class == ELFCLASS32 \
|
||||
? (void *) &ph32 \
|
||||
: (void *) &ph64)
|
||||
#define ph_size (class == ELFCLASS32 \
|
||||
? sizeof ph32 \
|
||||
: sizeof ph64)
|
||||
#define ph_type (class == ELFCLASS32 \
|
||||
? getu32(swap, ph32.p_type) \
|
||||
: getu32(swap, ph64.p_type))
|
||||
@ -129,11 +135,14 @@ doshn(int class, int swap, int fd, off_t off, int num, size_t size)
|
||||
Elf32_Shdr sh32;
|
||||
Elf64_Shdr sh64;
|
||||
|
||||
if (size != sh_size)
|
||||
error("corrupted section header size.\n");
|
||||
|
||||
if (lseek(fd, off, SEEK_SET) == -1)
|
||||
error("lseek failed (%s).\n", strerror(errno));
|
||||
|
||||
for ( ; num; num--) {
|
||||
if (read(fd, sh_addr, size) == -1)
|
||||
if (read(fd, sh_addr, sh_size) == -1)
|
||||
error("read failed (%s).\n", strerror(errno));
|
||||
if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
|
||||
(void) printf (", not stripped");
|
||||
@ -162,11 +171,13 @@ dophn_exec(int class, int swap, int fd, off_t off, int num, size_t size)
|
||||
size_t offset, nameoffset;
|
||||
off_t savedoffset;
|
||||
|
||||
if (size != ph_size)
|
||||
error("corrupted program header size.\n");
|
||||
if (lseek(fd, off, SEEK_SET) == -1)
|
||||
error("lseek failed (%s).\n", strerror(errno));
|
||||
|
||||
for ( ; num; num--) {
|
||||
if (read(fd, ph_addr, size) == -1)
|
||||
if (read(fd, ph_addr, ph_size) == -1)
|
||||
error("read failed (%s).\n", strerror(errno));
|
||||
if ((savedoffset = lseek(fd, 0, SEEK_CUR)) == -1)
|
||||
error("lseek failed (%s).\n", strerror(errno));
|
||||
@ -360,13 +371,15 @@ dophn_core(int class, int swap, int fd, off_t off, int num, size_t size)
|
||||
int bufsize;
|
||||
int os_style = -1;
|
||||
|
||||
if (size != ph_size)
|
||||
error("corrupted program header size.\n");
|
||||
/*
|
||||
* Loop through all the program headers.
|
||||
*/
|
||||
for ( ; num; num--) {
|
||||
if (lseek(fd, off, SEEK_SET) == -1)
|
||||
error("lseek failed (%s).\n", strerror(errno));
|
||||
if (read(fd, ph_addr, size) == -1)
|
||||
if (read(fd, ph_addr, ph_size) == -1)
|
||||
error("read failed (%s).\n", strerror(errno));
|
||||
off += size;
|
||||
if (ph_type != PT_NOTE)
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: softmagic.c,v 1.52 2003/02/08 18:33:53 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: softmagic.c,v 1.54 2003/02/25 13:04:32 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
static int match(struct magic *, uint32_t, unsigned char *, int);
|
||||
@ -105,7 +105,8 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes)
|
||||
int firstline = 1; /* a flag to print X\n X\n- X */
|
||||
|
||||
if (tmpoff == NULL)
|
||||
if ((tmpoff = (int32_t *) malloc(tmplen = 20)) == NULL)
|
||||
if ((tmpoff = (int32_t *) malloc(
|
||||
(tmplen = 20) * sizeof(*tmpoff))) == NULL)
|
||||
error("out of memory\n");
|
||||
|
||||
for (magindex = 0; magindex < nmagic; magindex++) {
|
||||
@ -137,7 +138,7 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes)
|
||||
/* and any continuations that match */
|
||||
if (++cont_level >= tmplen)
|
||||
if ((tmpoff = (int32_t *) realloc(tmpoff,
|
||||
tmplen += 20)) == NULL)
|
||||
(tmplen += 20) * sizeof(*tmpoff))) == NULL)
|
||||
error("out of memory\n");
|
||||
while (magic[magindex+1].cont_level != 0 &&
|
||||
++magindex < nmagic) {
|
||||
@ -184,7 +185,8 @@ match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes)
|
||||
if (++cont_level >= tmplen)
|
||||
if ((tmpoff =
|
||||
(int32_t *) realloc(tmpoff,
|
||||
tmplen += 20)) == NULL)
|
||||
(tmplen += 20)
|
||||
* sizeof(*tmpoff))) == NULL)
|
||||
error("out of memory\n");
|
||||
}
|
||||
if (magic[magindex].flag & OFFADD) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user