Commit 7e650197 authored by Xin LI's avatar Xin LI
Browse files

Vendor import of file 5.22.

parent a12836ac
2015-01-02 15:15 Christos Zoulas <christos@zoulas.com>
* release 5.22
2015-01-01 12:01 Christos Zoulas <christos@zoulas.com>
* add indirect relative for TIFF/Exif
2014-12-16 18:10 Christos Zoulas <christos@zoulas.com>
* restructure elf note printing to avoid repeated messages
* add note limit, suggested by Alexander Cherepanov
2014-12-16 16:53 Christos Zoulas <christos@zoulas.com>
* Bail out on partial pread()'s (Alexander Cherepanov)
* Fix incorrect bounds check in file_printable (Alexander Cherepanov)
2014-12-11 20:01 Christos Zoulas <christos@zoulas.com>
* PR/405: ignore SIGPIPE from uncompress programs
* change printable -> file_printable and use it in
more places for safety
* in ELF, instead of "(uses dynamic libraries)" when PT_INTERP
is present print the interpreter name.
2014-12-10 20:01 Christos Zoulas <christos@zoulas.com>
* release 5.21
......@@ -23,6 +49,8 @@
- reduce the number of recursion levels from 20 to 10
- preserve error messages in indirect magic handling
This is tracked as CVE-2014-8116 and CVE-2014-8117
2014-11-12 10:30 Christos Zoulas <christos@zoulas.com>
* fix bogus free in the user buffer case.
......
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
......@@ -618,10 +618,9 @@ distcheck: dist
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
......
## README for file(1) Command ##
@(#) $File: README,v 1.48 2014/03/07 13:55:30 christos Exp $
@(#) $File: README,v 1.49 2015/01/02 20:23:04 christos Exp $
Mailing List: file@mx.gw.com
Mailing List archives: http://mx.gw.com/pipermail/file/
......@@ -25,8 +25,8 @@ A public read-only git repository of the same sources is available at:
https://github.com/file/file
The major changes for 5.x are CDF file parsing, indirect magic, and
overhaul in mime and ascii encoding handling.
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
......@@ -67,33 +67,41 @@ 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/asctime_r.c - replacement for OS's that don't have it.
src/apptype.c - used for OS/2 specific application type magic
src/asprintf.c - replacement for OS's that don't have it.
src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
src/asctime_r.c - for systems that don't have it.
src/asprintf.c - for systems that don't have it.
src/cdf.c - parser for Microsoft Compound Document Files
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/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 - for systems that don't have it.
src/ctime_r.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/getopt_long.c - for systems that don't have it.
src/getline.c - for systems that don't have it.
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/is_tar.c, tar.h - knows about tarchives (courtesy John Gilmore).
src/names.h - header file for ascmagic.c
src/magic.h.in - source file for magic.h
src/magic.c - the libmagic api
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/strlcat.c - for systems that don't have it.
src/strlcpy.c - for systems that don't have it.
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/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.
......
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# generated automatically by aclocal 1.14 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
......@@ -21,7 +21,7 @@ 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 5 (gettext-0.18.2)
dnl Copyright (C) 2005, 2008, 2010-2014 Free Software Foundation, Inc.
dnl Copyright (C) 2005, 2008, 2010-2013 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.
......@@ -113,7 +113,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [],
m4_if([$1], [1.14], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
......@@ -129,7 +129,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl
[AM_AUTOMAKE_VERSION([1.14])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for file 5.21.
# Generated by GNU Autoconf 2.69 for file 5.22.
#
# Report bugs to <christos@astron.com>.
#
......@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='file'
PACKAGE_TARNAME='file'
PACKAGE_VERSION='5.21'
PACKAGE_STRING='file 5.21'
PACKAGE_VERSION='5.22'
PACKAGE_STRING='file 5.22'
PACKAGE_BUGREPORT='christos@astron.com'
PACKAGE_URL=''
......@@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures file 5.21 to adapt to many kinds of systems.
\`configure' configures file 5.22 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1397,7 +1397,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of file 5.21:";;
short | recursive ) echo "Configuration of file 5.22:";;
esac
cat <<\_ACEOF
......@@ -1507,7 +1507,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
file configure 5.21
file configure 5.22
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by file $as_me 5.21, which was
It was created by file $as_me 5.22, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -3029,7 +3029,7 @@ fi
# Define the identity of the package.
PACKAGE='file'
VERSION='5.21'
VERSION='5.22'
cat >>confdefs.h <<_ACEOF
......@@ -14998,7 +14998,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.21, which was
This file was extended by file $as_me 5.22, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -15064,7 +15064,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.21
file config.status 5.22
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
dnl Process this file with autoconf to produce a configure script.
AC_INIT([file],[5.21],[christos@astron.com])
AC_INIT([file],[5.22],[christos@astron.com])
AM_INIT_AUTOMAKE([subdir-objects foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
......
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
......
.\" $File: file.man,v 1.110 2014/11/28 02:46:39 christos Exp $
.Dd November 27, 2014
.\" $File: file.man,v 1.111 2014/12/16 23:18:40 christos Exp $
.Dd December 16, 2014
.Dt FILE __CSECTION__
.Os
.Sh NAME
......@@ -310,6 +310,7 @@ Set various parameter limits.
.It Sy "Name" Ta Sy "Default" Ta Sy "Explanation"
.It Li indir Ta 15 Ta recursion limit for indirect magic
.It Li name Ta 30 Ta use count limit for name/use magic
.It Li elf_notes Ta 256 Ta max ELF notes processed
.It Li elf_phnum Ta 128 Ta max ELF program sections processed
.It Li elf_shnum Ta 32768 Ta max ELF sections processed
.El
......
.\" $File: libmagic.man,v 1.33 2014/11/28 02:46:39 christos Exp $
.\" $File: libmagic.man,v 1.34 2014/12/16 23:18:40 christos Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003.
.\" All Rights Reserved.
......@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd November 27, 2014
.Dd December 16, 2014
.Dt LIBMAGIC 3
.Os
.Sh NAME
......@@ -284,6 +284,7 @@ library.
.It Sy "Parameter" Ta Sy "Type" Ta Sy "Default"
.It Li MAGIC_PARAM_INDIR_MAX Ta size_t Ta 15
.It Li MAGIC_PARAM_NAME_MAX Ta size_t Ta 30
.It Li MAGIC_PARAM_ELF_NOTES_MAX Ta size_t Ta 256
.It Li MAGIC_PARAM_ELF_PHNUM_MAX Ta size_t Ta 128
.It Li MAGIC_PARAM_ELF_SHNUM_MAX Ta size_t Ta 32768
.El
......@@ -303,12 +304,16 @@ The
parameter controls the maximum number of calls for name/use.
.Pp
The
.Dv MAGIC_PARAM_NOTES_MAX
parameter controls how many ELF notes will be processed.
.Pp
The
.Dv MAGIC_PARAM_PHNUM_MAX
parameter controls how many elf program sections will be processed.
parameter controls how many ELF program sections will be processed.
.Pp
The
.Dv MAGIC_PARAM_SHNUM_MAX
parameter controls how many elf sections will be processed.
parameter controls how many ELF sections will be processed.
.Pp
The
.Fn magic_version
......
.\" $File: magic.man,v 1.84 2014/06/03 19:01:34 christos Exp $
.Dd June 3, 2014
.\" $File: magic.man,v 1.85 2015/01/01 17:07:34 christos Exp $
.Dd January 1, 2015
.Dt MAGIC __FSECTION__
.Os
.\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
......@@ -200,6 +200,11 @@ interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv indirect
Starting at the given offset, consult the magic database again.
The offset of th
.Dv indirect
magic is by default absolute in the file, but one can specify
.Dv /r
to indicate that the offset is relative from the beginning of the entry.
.It Dv name
Define a
.Dq named
......
......@@ -2,6 +2,6 @@
#------------------------------------------------------------------------------
# Localstuff: file(1) magic for locally observed files
#
# $File: Localstuff,v 1.5 2007/01/12 17:38:27 christos Exp $
# $File: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $
# Add any locally observed files here. Remember:
# text if readable, executable if runnable binary, data if unreadable.
#------------------------------------------------------------------------------
# $File: cafebabe,v 1.16 2014/04/30 21:41:02 christos Exp $
# $File: cafebabe,v 1.17 2015/01/01 17:07:00 christos Exp $
# Cafe Babes unite!
#
# Since Java bytecode and Mach-O universal binaries have the same magic number,
......@@ -45,7 +45,7 @@
0 name mach-o \b [
>0 use mach-o-cpu \b
>&(8.L) indirect \b:
>(8.L) indirect \b:
>0 belong x \b]
0 belong 0xcafebabe
......
#------------------------------------------------------------------------------
# $File: filesystems,v 1.107 2014/12/03 18:02:52 christos Exp $
# $File: filesystems,v 1.108 2015/01/01 17:43:47 christos Exp $
# filesystems: file(1) magic for different filesystems
#
0 name partid
......@@ -260,6 +260,13 @@
>>(11.s-2) uleshort 0xAA55 DOS/MBR boot sector
# for sector sizes with 512 or more Bytes
>0x1FE leshort 0xAA55 DOS/MBR boot sector
# 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
#
# to display information (50) before DOS BPB (strength=70) and after DOS floppy (120) like in old file version
!:strength +65
>2 string OSBS OS/BS MBR
# added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/
# and http://en.wikipedia.org/wiki/Master_Boot_Record
......
#------------------------------------------------------------------------------
# $File: images,v 1.97 2014/12/08 16:06:19 christos Exp $
# $File: images,v 1.102 2015/01/02 02:36:35 christos Exp $
# images: file(1) magic for image formats (see also "iff", and "c-lang" for
# XPM bitmaps)
#
......@@ -115,7 +115,7 @@
# never changed. The TIFF specification recommends testing for it.
0 string MM\x00\x2a TIFF image data, big-endian
!:mime image/tiff
>(4.L) use tiff_ifd
>(4.L) use \^tiff_ifd
0 string II\x2a\x00 TIFF image data, little-endian
!:mime image/tiff
>(4.l) use tiff_ifd
......@@ -125,54 +125,57 @@
>2 use tiff_entry
0 name tiff_entry
# NewSubFileType
>0 leshort 0xfe
>>12 use tiff_entry
>0 leshort 0x100
>>4 lelong 1
>>>12 use tiff_entry
>>>8 lelong x \b, width=%d
>>>8 leshort x \b, width=%d
>0 leshort 0x101
>>4 lelong 1
>>>8 lelong x \b, height=%d
>>>8 leshort x \b, height=%d
>>>12 use tiff_entry
>0 leshort 0x102
>>8 lelong x \b, bps=%d
>>8 leshort x \b, bps=%d
>>12 use tiff_entry
>0 leshort 0x103
>>4 lelong 1 \b, compression=
>>>8 lelong 1 \bnone
>>>8 lelong 2 \bhuffman
>>>8 lelong 3 \bbi-level group 3
>>>8 lelong 4 \bbi-level group 4
>>>8 lelong 5 \bLZW
>>>8 lelong 6 \bJPEG (old)
>>>8 lelong 7 \bJPEG
>>>8 lelong 8 \bdeflate
>>>8 lelong 9 \bJBIG, ITU-T T.85
>>>8 lelong 0xa \bJBIG, ITU-T T.43
>>>8 lelong 0x7ffe \bNeXT RLE 2-bit
>>>8 lelong 0x8005 \bPackBits (Macintosh RLE)
>>>8 lelong 0x8029 \bThunderscan RLE
>>>8 lelong 0x807f \bRasterPadding (CT or MP)
>>>8 lelong 0x8080 \bRLE (Line Work)
>>>8 lelong 0x8081 \bRLE (High-Res Cont-Tone)
>>>8 lelong 0x8082 \bRLE (Binary Line Work)
>>>8 lelong 0x80b2 \bDeflate (PKZIP)
>>>8 lelong 0x80b3 \bKodak DCS
>>>8 lelong 0x8765 \bJBIG
>>>8 lelong 0x8798 \bJPEG2000
>>>8 lelong 0x8799 \bNikon NEF Compressed
>>>8 leshort 1 \bnone
>>>8 leshort 2 \bhuffman
>>>8 leshort 3 \bbi-level group 3
>>>8 leshort 4 \bbi-level group 4
>>>8 leshort 5 \bLZW
>>>8 leshort 6 \bJPEG (old)
>>>8 leshort 7 \bJPEG
>>>8 leshort 8 \bdeflate
>>>8 leshort 9 \bJBIG, ITU-T T.85
>>>8 leshort 0xa \bJBIG, ITU-T T.43
>>>8 leshort 0x7ffe \bNeXT RLE 2-bit
>>>8 leshort 0x8005 \bPackBits (Macintosh RLE)
>>>8 leshort 0x8029 \bThunderscan RLE
>>>8 leshort 0x807f \bRasterPadding (CT or MP)
>>>8 leshort 0x8080 \bRLE (Line Work)
>>>8 leshort 0x8081 \bRLE (High-Res Cont-Tone)
>>>8 leshort 0x8082 \bRLE (Binary Line Work)
>>>8 leshort 0x80b2 \bDeflate (PKZIP)
>>>8 leshort 0x80b3 \bKodak DCS
>>>8 leshort 0x8765 \bJBIG
>>>8 leshort 0x8798 \bJPEG2000
>>>8 leshort 0x8799 \bNikon NEF Compressed
>>>8 default x
>>>>8 lelong x \b(unknown 0x%x)
>>>>8 leshort x \b(unknown 0x%x)
>>>12 use tiff_entry
>0 leshort 0x106 \b, PhotometricIntepretation=
>>8 lelong 0 \bWhiteIsZero
>>8 lelong 1 \bBlackIsZero
>>8 lelong 2 \bRGB
>>8 lelong 3 \bRGB Palette
>>8 lelong 4 \bTransparency Mask
>>8 lelong 5 \bCMYK
>>8 lelong 6 \bYCbCr
>>8 lelong 8 \bCIELab
>>>8 lelong x \b(unknown=0x%x)
>>8 leshort 0 \bWhiteIsZero
>>8 leshort 1 \bBlackIsZero
>>8 leshort 2 \bRGB
>>8 leshort 3 \bRGB Palette
>>8 leshort 4 \bTransparency Mask
>>8 leshort 5 \bCMYK
>>8 leshort 6 \bYCbCr
>>8 leshort 8 \bCIELab
>>>8 leshort x \b(unknown=0x%x)
>>12 use tiff_entry
# FillOrder
>0 leshort 0x10a
......@@ -186,21 +189,79 @@
>0 leshort 0x10e
>>(8.l) string x \b, description=%s
>>>12 use tiff_entry
# Make
>0 leshort 0x10f
>>(8.l) string x \b, manufacturer=%s
>>>12 use tiff_entry
# Model
>0 leshort 0x110
>>(8.l) string x \b, model=%s
>>>12 use tiff_entry
# StripOffsets
>0 leshort 0x111
>>12 use tiff_entry
# NewSubFileType
>0 leshort 0xfe
# Orientation
>0 leshort 0x112 \b, orientation=
>>8 leshort 1 \bupper-left
>>8 leshort 3 \blower-right
>>8 leshort 6 \bupper-right
>>8 leshort 8 \blower-left
>>8 leshort 9 \bundefined
>>8 default x
>>>8 leshort x \b[*%d*]
>>12 use tiff_entry
# XResolution
>0 leshort 0x11a
>>8 lelong x \b, xresolution=%d
>>12 use tiff_entry
# YResolution
>0 leshort 0x11b
>>8 lelong x \b, yresolution=%d
>>12 use tiff_entry
# ResolutionUnit
>0 leshort 0x128
>>8 leshort x \b, resolutionunit=%d
>>12 use tiff_entry
# Software
>0 leshort 0x131
>>(8.l) string x \b, software=%s
>>12 use tiff_entry
# Datetime
>0 leshort 0x132
>>(8.l) string x \b, datetime=%s
>>>12 use tiff_entry
>>12 use tiff_entry
# HostComputer
>0 leshort 0x13c
>>(8.l) string x \b, hostcomputer=%s
>>>12 use tiff_entry
>>12 use tiff_entry
# WhitePoint
>0 leshort 0x13e
>>12 use tiff_entry
# PrimaryChromaticities
>0 leshort 0x13f
>>12 use tiff_entry
# YCbCrCoefficients
>0 leshort 0x211
>>12 use tiff_entry
# YCbCrPositioning
>0 leshort 0x213
>>12 use tiff_entry
# ReferenceBlackWhite
>0 leshort 0x214
>>12 use tiff_entry
# Copyright
>0 leshort 0x8298
>>(8.l) string x \b, copyright=%s
>>12 use tiff_entry
# ExifOffset
>0 leshort 0x8769
>>12 use tiff_entry
# GPS IFD
>0 leshort 0x8825 \b, GPS-Data
>>12 use tiff_entry
#>0 leshort x \b, unknown=0x%x
#>>12 use tiff_entry
0 string MM\x00\x2b Big TIFF image data, big-endian
!:mime image/tiff
......
#------------------------------------------------------------------------------
# $File: jpeg,v 1.21 2014/09/12 20:47:00 christos Exp $
# $File: jpeg,v 1.25 2015/01/02 16:56:50 christos Exp $
# JPEG images
# SunOS 5.5.1 had
#
......@@ -31,98 +31,9 @@
# Next, show thumbnail info, if it exists:
>>18 byte !0 \b, thumbnail %dx
>>>19 byte x \b%d
# EXIF moved down here to avoid reporting a bogus version number,
# and EXIF version number printing added.
# - Patrik R=E5dman <patrik+file-magic@iki.fi>
>6 string Exif \b, EXIF standard
# Look for EXIF IFD offset in IFD 0, and then look for EXIF version tag in EXIF IFD.
# All possible combinations of entries have to be enumerated, since no looping
# is possible. And both endians are possible...
# The combinations included below are from real-world JPEGs.
# Little-endian
>>12 string II
# IFD 0 Entry #5:
>>>70 leshort 0x8769
# EXIF IFD Entry #1:
>>>>(78.l+14) leshort 0x9000
>>>>>(78.l+23) byte x %c
>>>>>(78.l+24) byte x \b.%c
>>>>>(78.l+25) byte !0x30 \b%c
# IFD 0 Entry #9:
>>>118 leshort 0x8769
# EXIF IFD Entry #3:
>>>>(126.l+38) leshort 0x9000
>>>>>(126.l+47) byte x %c
>>>>>(126.l+48) byte x \b.%c
>>>>>(126.l+49) byte !0x30 \b%c
# IFD 0 Entry #10
>>>130 leshort 0x8769
# EXIF IFD Entry #3:
>>>>(138.l+38) leshort 0x9000
>>>>>(138.l+47) byte x %c
>>>>>(138.l+48) byte x \b.%c
>>>>>(138.l+49) byte !0x30 \b%c
# EXIF IFD Entry #4:
>>>>(138.l+50) leshort 0x9000
>>>>>(138.l+59) byte x %c
>>>>>(138.l+60) byte x \b.%c
>>>>>(138.l+61) byte !0x30 \b%c
# EXIF IFD Entry #5:
>>>>(138.l+62) leshort 0x9000
>>>>>(138.l+71) byte x %c
>>>>>(138.l+72) byte x \b.%c
>>>>>(138.l+73) byte !0x30 \b%c
# IFD 0 Entry #11
>>>142 leshort 0x8769
# EXIF IFD Entry #3:
>>>>(150.l+38) leshort 0x9000
>>>>>(150.l+47) byte x %c
>>>>>(150.l+48) byte x \b.%c
>>>>>(150.l+49) byte !0x30 \b%c
# EXIF IFD Entry #4:
>>>>(150.l+50) leshort 0x9000
>>>>>(150.l+59) byte x %c
>>>>>(150.l+60) byte x \b.%c
>>>>>(150.l+61) byte !0x30 \b%c
# EXIF IFD Entry #5:
>>>>(150.l+62) leshort 0x9000
>>>>>(150.l+71) byte x %c
>>>>>(150.l+72) byte x \b.%c
>>>>>(150.l+73) byte !0x30 \b%c
# Big-endian
>>12 string MM
# IFD 0 Entry #9:
>>>118 beshort 0x8769
# EXIF IFD Entry #1:
>>>>(126.L+14) beshort 0x9000
>>>>>(126.L+23) byte x %c
>>>>>(126.L+24) byte x \b.%c
>>>>>(126.L+25) byte !0x30 \b%c
# EXIF IFD Entry #3:
>>>>(126.L+38) beshort 0x9000
>>>>>(126.L+47) byte x %c
>>>>>(126.L+48) byte x \b.%c
>>>>>(126.L+49) byte !0x30 \b%c
# IFD 0 Entry #10