Browse Source

Import upstream version 5.19

Christos Zoulas 9 years ago
parent
commit
463c3112b3
99 changed files with 1615 additions and 1127 deletions
  1. 57 4
      ChangeLog
  2. 14 0
      config.h.in
  3. 83 10
      configure
  4. 3 1
      configure.ac
  5. 19 10
      doc/magic.man
  6. 7 7
      magic/Magdir/android
  7. 6 6
      magic/Magdir/animation
  8. 5 5
      magic/Magdir/apple
  9. 70 6
      magic/Magdir/archive
  10. 5 5
      magic/Magdir/att3b
  11. 3 3
      magic/Magdir/audio
  12. 2 2
      magic/Magdir/bflt
  13. 4 4
      magic/Magdir/bsdi
  14. 2 2
      magic/Magdir/c-lang
  15. 2 2
      magic/Magdir/cafebabe
  16. 2 2
      magic/Magdir/clarion
  17. 2 2
      magic/Magdir/claris
  18. 3 3
      magic/Magdir/clipper
  19. 2 2
      magic/Magdir/commands
  20. 10 3
      magic/Magdir/compress
  21. 4 4
      magic/Magdir/cups
  22. 11 11
      magic/Magdir/database
  23. 5 5
      magic/Magdir/dump
  24. 50 40
      magic/Magdir/dyadic
  25. 2 2
      magic/Magdir/efi
  26. 15 1
      magic/Magdir/elf
  27. 3 3
      magic/Magdir/encore
  28. 70 132
      magic/Magdir/filesystems
  29. 18 8
      magic/Magdir/flash
  30. 3 3
      magic/Magdir/fonts
  31. 2 2
      magic/Magdir/fortran
  32. 10 10
      magic/Magdir/games
  33. 3 3
      magic/Magdir/gimp
  34. 3 3
      magic/Magdir/gnome
  35. 1 2
      magic/Magdir/gpt
  36. 3 3
      magic/Magdir/graphviz
  37. 15 15
      magic/Magdir/hp
  38. 5 5
      magic/Magdir/ibm370
  39. 22 19
      magic/Magdir/images
  40. 6 6
      magic/Magdir/intel
  41. 1 1
      magic/Magdir/isz
  42. 2 2
      magic/Magdir/karma
  43. 18 1
      magic/Magdir/linux
  44. 53 53
      magic/Magdir/mach
  45. 25 0
      magic/Magdir/map
  46. 6 6
      magic/Magdir/marc21
  47. 23 23
      magic/Magdir/mips
  48. 15 15
      magic/Magdir/motorola
  49. 26 104
      magic/Magdir/msdos
  50. 1 1
      magic/Magdir/msx
  51. 2 2
      magic/Magdir/natinst
  52. 8 8
      magic/Magdir/ncr
  53. 7 7
      magic/Magdir/netbsd
  54. 1 1
      magic/Magdir/nitpicker
  55. 2 2
      magic/Magdir/oasis
  56. 7 3
      magic/Magdir/palm
  57. 4 4
      magic/Magdir/pdp
  58. 32 1
      magic/Magdir/perl
  59. 19 3
      magic/Magdir/printer
  60. 2 2
      magic/Magdir/python
  61. 3 3
      magic/Magdir/riff
  62. 6 6
      magic/Magdir/scientific
  63. 19 9
      magic/Magdir/sequent
  64. 24 0
      magic/Magdir/sereal
  65. 9 9
      magic/Magdir/sgi
  66. 2 2
      magic/Magdir/sharc
  67. 2 2
      magic/Magdir/sql
  68. 19 19
      magic/Magdir/sun
  69. 1 1
      magic/Magdir/symbos
  70. 2 2
      magic/Magdir/sysex
  71. 2 2
      magic/Magdir/ti-8x
  72. 3 3
      magic/Magdir/troff
  73. 1 1
      magic/Magdir/uterus
  74. 2 2
      magic/Magdir/varied.out
  75. 3 3
      magic/Magdir/vax
  76. 104 8
      magic/Magdir/virtual
  77. 6 6
      magic/Magdir/vorbis
  78. 2 2
      magic/Magdir/windows
  79. 2 2
      magic/Magdir/xilinx
  80. 7 7
      magic/Magdir/xwindows
  81. 4 4
      magic/Magdir/zfs
  82. 3 1
      magic/Makefile.am
  83. 3 1
      magic/Makefile.in
  84. 21 14
      python/magic.py
  85. 3 3
      src/Makefile.in
  86. 92 41
      src/apprentice.c
  87. 45 26
      src/cdf.c
  88. 3 0
      src/cdf.h
  89. 4 3
      src/cdf_time.c
  90. 16 3
      src/file.h
  91. 37 4
      src/fsmagic.c
  92. 48 16
      src/funcs.c
  93. 46 14
      src/magic.c
  94. 1 1
      src/magic.h
  95. 53 20
      src/readcdf.c
  96. 31 1
      src/readelf.c
  97. 173 283
      src/softmagic.c
  98. 2 0
      src/strcasestr.c
  99. 5 8
      src/vasprintf.c

+ 57 - 4
ChangeLog

@@ -1,10 +1,63 @@
+2014-06-12  12:28  Christos Zoulas <christos@zoulas.com>
+
+	* release 5.19
+
+2014-06-09   9:04  Christos Zoulas <christos@zoulas.com>
+	
+	* Misc buffer overruns and missing buffer size tests in cdf parsing
+	  (Francisco Alonso, Jan Kaluza)
+
+2014-06-02  14:50  Christos Zoulas <christos@zoulas.com>
+
+	* Enforce limit of 8K on regex searches that have no limits
+	* Allow the l modifier for regex to mean line count. Default
+	  to byte count. If line count is specified, assume a max
+	  of 80 characters per line to limit the byte count.
+	* Don't allow conversions to be used for dates, allowing
+	  the mask field to be used as an offset.
+
+2014-05-30  12:51  Christos Zoulas <christos@zoulas.com>
+
+	* Make the range operator limit the length of the
+	  regex search.
+
+2014-05-14  19:23  Christos Zoulas <christos@zoulas.com>
+
+	* PR/347: Windows fixes
+	* PR/352: Hangul word processor recognition
+	* PR/354: Encoding irregularities in text files
+
+2014-05-06  6:12  Christos Zoulas <christos@zoulas.com>
+
+	* Fix uninitialized title in CDF files (Jan Kaluza)
+
+2014-05-04  14:55  Christos Zoulas <christos@zoulas.com>
+
+	* PR/351: Fix compilation of empty files 
+
+2014-04-30  17:39  Christos Zoulas <christos@zoulas.com>
+
+	* Fix integer formats: We don't specify 'l' or
+	  'h' and 'hh' specifiers anymore, only 'll' for
+	  quads and nothing for the rest. This is so that
+	  magic writing is simpler.
+
+2014-04-01  15:25  Christos Zoulas <christos@zoulas.com>
+
+	* PR/341: Jan Kaluza, fix memory leak
+	* PR/342: Jan Kaluza, fix out of bounds read
+
+2014-03-28  15:25  Christos Zoulas <christos@zoulas.com>
+
+	* Fix issue with long formats not matching fmtcheck
+
 2014-03-26  11:25  Christos Zoulas <christos@zoulas.com>
 2014-03-26  11:25  Christos Zoulas <christos@zoulas.com>
 
 
 	* release 5.18
 	* release 5.18
 
 
 2014-03-15  17:45  Christos Zoulas <christos@zoulas.com>
 2014-03-15  17:45  Christos Zoulas <christos@zoulas.com>
 
 
-        * add fmtcheck(3) for those who don't have it
+	* add fmtcheck(3) for those who don't have it
 
 
 2014-03-14  15:12  Christos Zoulas <christos@zoulas.com>
 2014-03-14  15:12  Christos Zoulas <christos@zoulas.com>
 
 
@@ -1040,7 +1093,7 @@
 
 
 	* Identify gnu tar vs. posix tar
 	* Identify gnu tar vs. posix tar
 
 
-	* When keep going, don't print spurious newlines (Radek Vokál)
+	* When keep going, don't print spurious newlines (Radek Vokal)
 
 
 2006-04-01 12:02 Christos Zoulas <christos@astron.com>
 2006-04-01 12:02 Christos Zoulas <christos@astron.com>
 
 
@@ -1064,7 +1117,7 @@
 2005-10-31 8:54 Christos Zoulas <christos@astron.com>
 2005-10-31 8:54 Christos Zoulas <christos@astron.com>
 
 
 	* Fix regression where the core info was not completely processed
 	* Fix regression where the core info was not completely processed
-	    (Radek Vokál)
+	    (Radek Vokal)
 
 
 2005-10-20 11:15 Christos Zoulas <christos@astron.com>
 2005-10-20 11:15 Christos Zoulas <christos@astron.com>
 
 
@@ -1081,7 +1134,7 @@
 2005-09-20 13:33 Christos Zoulas <christos@astron.com>
 2005-09-20 13:33 Christos Zoulas <christos@astron.com>
 
 
 	* Don't print SVR4 Style in core files multiple times
 	* Don't print SVR4 Style in core files multiple times
-	    (Radek Vokál)
+	    (Radek Vokal)
 
 
 2005-08-27 04:09 Christos Zoulas <christos@astron.com>
 2005-08-27 04:09 Christos Zoulas <christos@astron.com>
 
 

+ 14 - 0
config.h.in

@@ -59,6 +59,9 @@
 /* Define to 1 if you have the `getpagesize' function. */
 /* Define to 1 if you have the `getpagesize' function. */
 #undef HAVE_GETPAGESIZE
 #undef HAVE_GETPAGESIZE
 
 
+/* Define to 1 if the system has the type `intptr_t'. */
+#undef HAVE_INTPTR_T
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 #undef HAVE_INTTYPES_H
 
 
@@ -173,6 +176,9 @@
 /* HAVE_TZNAME */
 /* HAVE_TZNAME */
 #undef HAVE_TZNAME
 #undef HAVE_TZNAME
 
 
+/* Define to 1 if the system has the type `uintptr_t'. */
+#undef HAVE_UINTPTR_T
+
 /* Define to 1 if you have the <unistd.h> header file. */
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 #undef HAVE_UNISTD_H
 
 
@@ -342,6 +348,10 @@
    such a type exists and the standard includes do not define it. */
    such a type exists and the standard includes do not define it. */
 #undef int64_t
 #undef int64_t
 
 
+/* Define to the type of a signed integer type wide enough to hold a pointer,
+   if such a type exists, and if the system does not define it. */
+#undef intptr_t
+
 /* Define to a type if <wchar.h> does not define. */
 /* Define to a type if <wchar.h> does not define. */
 #undef mbstate_t
 #undef mbstate_t
 
 
@@ -370,5 +380,9 @@
    such a type exists and the standard includes do not define it. */
    such a type exists and the standard includes do not define it. */
 #undef uint8_t
 #undef uint8_t
 
 
+/* Define to the type of an unsigned integer type wide enough to hold a
+   pointer, if such a type exists, and if the system does not define it. */
+#undef uintptr_t
+
 /* Define as `fork' if `vfork' does not work. */
 /* Define as `fork' if `vfork' does not work. */
 #undef vfork
 #undef vfork

+ 83 - 10
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for file 5.18.
+# Generated by GNU Autoconf 2.69 for file 5.19.
 #
 #
 # Report bugs to <christos@astron.com>.
 # Report bugs to <christos@astron.com>.
 #
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 # Identity of this package.
 PACKAGE_NAME='file'
 PACKAGE_NAME='file'
 PACKAGE_TARNAME='file'
 PACKAGE_TARNAME='file'
-PACKAGE_VERSION='5.18'
-PACKAGE_STRING='file 5.18'
+PACKAGE_VERSION='5.19'
+PACKAGE_STRING='file 5.19'
 PACKAGE_BUGREPORT='christos@astron.com'
 PACKAGE_BUGREPORT='christos@astron.com'
 PACKAGE_URL=''
 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.
   # 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.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
   cat <<_ACEOF
-\`configure' configures file 5.18 to adapt to many kinds of systems.
+\`configure' configures file 5.19 to adapt to many kinds of systems.
 
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
 
@@ -1397,7 +1397,7 @@ fi
 
 
 if test -n "$ac_init_help"; then
 if test -n "$ac_init_help"; then
   case $ac_init_help in
   case $ac_init_help in
-     short | recursive ) echo "Configuration of file 5.18:";;
+     short | recursive ) echo "Configuration of file 5.19:";;
    esac
    esac
   cat <<\_ACEOF
   cat <<\_ACEOF
 
 
@@ -1507,7 +1507,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
 if $ac_init_version; then
   cat <<\_ACEOF
   cat <<\_ACEOF
-file configure 5.18
+file configure 5.19
 generated by GNU Autoconf 2.69
 generated by GNU Autoconf 2.69
 
 
 Copyright (C) 2012 Free Software Foundation, Inc.
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 running configure, to aid debugging if configure makes a mistake.
 
 
-It was created by file $as_me 5.18, which was
+It was created by file $as_me 5.19, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
 
   $ $0 $@
   $ $0 $@
@@ -3029,7 +3029,7 @@ fi
 
 
 # Define the identity of the package.
 # Define the identity of the package.
  PACKAGE='file'
  PACKAGE='file'
- VERSION='5.18'
+ VERSION='5.19'
 
 
 
 
 cat >>confdefs.h <<_ACEOF
 cat >>confdefs.h <<_ACEOF
@@ -13634,6 +13634,79 @@ _ACEOF
 esac
 esac
 
 
 
 
+  ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = xyes; then :
+
+$as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h
+
+else
+  for ac_type in 'int' 'long int' 'long long int'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define intptr_t $ac_type
+_ACEOF
+
+	  ac_type=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test -z "$ac_type" && break
+     done
+fi
+
+
+
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = xyes; then :
+
+$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
+else
+  for ac_type in 'unsigned int' 'unsigned long int' \
+	'unsigned long long int'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define uintptr_t $ac_type
+_ACEOF
+
+	  ac_type=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test -z "$ac_type" && break
+     done
+fi
+
+
+
 
 
 
 
   for ac_header in $ac_header_list
   for ac_header in $ac_header_list
@@ -14925,7 +14998,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 # values after options handling.
 ac_log="
 ac_log="
-This file was extended by file $as_me 5.18, which was
+This file was extended by file $as_me 5.19, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_FILES    = $CONFIG_FILES
@@ -14991,7 +15064,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 ac_cs_version="\\
-file config.status 5.18
+file config.status 5.19
 configured by $0, generated by GNU Autoconf 2.69,
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
   with options \\"\$ac_cs_config\\"
 
 

+ 3 - 1
configure.ac

@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([file],[5.18],[christos@astron.com])
+AC_INIT([file],[5.19],[christos@astron.com])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 
@@ -107,6 +107,8 @@ AC_TYPE_UINT32_T
 AC_TYPE_INT32_T
 AC_TYPE_INT32_T
 AC_TYPE_UINT64_T
 AC_TYPE_UINT64_T
 AC_TYPE_INT64_T
 AC_TYPE_INT64_T
+AC_TYPE_INTPTR_T
+AC_TYPE_UINTPTR_T
 AC_FUNC_MMAP
 AC_FUNC_MMAP
 AC_FUNC_FORK
 AC_FUNC_FORK
 AC_FUNC_MBRTOWC
 AC_FUNC_MBRTOWC

+ 19 - 10
doc/magic.man

@@ -1,5 +1,5 @@
-.\" $File: magic.man,v 1.81 2014/03/08 17:28:08 christos Exp $
-.Dd April 22, 2013
+.\" $File: magic.man,v 1.84 2014/06/03 19:01:34 christos Exp $
+.Dd June 3, 2014
 .Dt MAGIC __FSECTION__
 .Dt MAGIC __FSECTION__
 .Os
 .Os
 .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
 .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
@@ -228,19 +228,25 @@ Regular expressions can take exponential time to process, and their
 performance is hard to predict, so their use is discouraged.
 performance is hard to predict, so their use is discouraged.
 When used in production environments, their performance
 When used in production environments, their performance
 should be carefully checked.
 should be carefully checked.
-The type specification can be optionally followed by
-.Dv /[c][s] .
+The size of the string to search should also be limited by specifying
+.Dv /<length> ,
+to avoid performance issues scanning long files.
+The type specification can also be optionally followed by
+.Dv /[c][s][l] .
 The
 The
 .Dq c
 .Dq c
 flag makes the match case insensitive, while the
 flag makes the match case insensitive, while the
 .Dq s
 .Dq s
 flag update the offset to the start offset of the match, rather than the end.
 flag update the offset to the start offset of the match, rather than the end.
-The regular expression is tested against line
-.Dv N + 1
-onwards, where
-.Dv N
-is the given offset.
-Line endings are assumed to be in the machine's native format.
+The
+.Dq l
+modifier, changes the limit of length to mean number of lines instead of a
+byte count.
+Lines are delimited by the platforms native line delimiter.
+When a line count is specified, an implicit byte count also computed assuming
+each line is 80 characters long.
+If neither a byte or line count is specified, the search is limited automatically
+to 8KiB.
 .Dv ^
 .Dv ^
 and
 and
 .Dv $
 .Dv $
@@ -409,6 +415,9 @@ is octal, and
 .Dv 0x13
 .Dv 0x13
 is hexadecimal.
 is hexadecimal.
 .Pp
 .Pp
+Numeric operations are not performed on date types, instead the numeric
+value is interpreted as an offset.
+.Pp
 For string values, the string from the
 For string values, the string from the
 file must match the specified string.
 file must match the specified string.
 The operators
 The operators

+ 7 - 7
magic/Magdir/android

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------
 #------------------------------------------------------------
-# $File: android,v 1.3 2013/11/08 01:24:22 christos Exp $
+# $File: android,v 1.4 2014/06/03 19:01:34 christos Exp $
 # Various android related magic entries
 # Various android related magic entries
 #------------------------------------------------------------
 #------------------------------------------------------------
 
 
@@ -89,12 +89,12 @@
 >17	string		0\n			\b, Not-Compressed
 >17	string		0\n			\b, Not-Compressed
 >17	string		1\n			\b, Compressed
 >17	string		1\n			\b, Compressed
 # any string as long as it's not the word none (which is matched below)
 # any string as long as it's not the word none (which is matched below)
->>19    regex/1		\^([^n\n]|n[^o]|no[^n]|non[^e]|none.+).*	\b, Encrypted (%s)
+>>19    regex/1l	\^([^n\n]|n[^o]|no[^n]|non[^e]|none.+).*	\b, Encrypted (%s)
 >>19	string		none\n			\b, Not-Encrypted
 >>19	string		none\n			\b, Not-Encrypted
 # Commented out because they don't seem useful to print
 # Commented out because they don't seem useful to print
 # (but they are part of the header - the tar file comes after them):
 # (but they are part of the header - the tar file comes after them):
-#>>>&1		regex/1 .*	\b, Password salt: %s
-#>>>>&1		regex/1 .*	\b, Master salt: %s
-#>>>>>&1	regex/1 .*	\b, PBKDF2 rounds: %s
-#>>>>>>&1	regex/1 .*	\b, IV: %s
-#>>>>>>>&1	regex/1 .*	\b, Key: %s
+#>>>&1		regex/1l .*	\b, Password salt: %s
+#>>>>&1		regex/1l .*	\b, Master salt: %s
+#>>>>>&1	regex/1l .*	\b, PBKDF2 rounds: %s
+#>>>>>>&1	regex/1l .*	\b, IV: %s
+#>>>>>>>&1	regex/1l .*	\b, Key: %s

+ 6 - 6
magic/Magdir/animation

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: animation,v 1.51 2014/03/14 18:47:29 christos Exp $
+# $File: animation,v 1.53 2014/04/30 21:41:02 christos Exp $
 # animation:  file(1) magic for animation/movie formats
 # animation:  file(1) magic for animation/movie formats
 #
 #
 # animation formats
 # animation formats
@@ -621,7 +621,7 @@
 # Live MPEG-4 audio streams (instead of RTP FlexMux)
 # Live MPEG-4 audio streams (instead of RTP FlexMux)
 0       beshort&0xFFE0  0x56E0         MPEG-4 LOAS
 0       beshort&0xFFE0  0x56E0         MPEG-4 LOAS
 !:mime	audio/x-mp4a-latm
 !:mime	audio/x-mp4a-latm
-#>1     beshort&0x1FFF  x              \b, %u byte packet
+#>1     beshort&0x1FFF  x              \b, %hu byte packet
 >3      byte&0xE0       0x40
 >3      byte&0xE0       0x40
 >>4     byte&0x3C       0x04           \b, single stream
 >>4     byte&0x3C       0x04           \b, single stream
 >>4     byte&0x3C       0x08           \b, 2 streams
 >>4     byte&0x3C       0x08           \b, 2 streams
@@ -719,16 +719,16 @@
 !:mime	video/x-mng
 !:mime	video/x-mng
 >4	belong			!0x0d0a1a0a	CORRUPTED,
 >4	belong			!0x0d0a1a0a	CORRUPTED,
 >4	belong			0x0d0a1a0a
 >4	belong			0x0d0a1a0a
->>16    belong	x				%ld x
->>20    belong	x				%ld
+>>16    belong	x				%d x
+>>20    belong	x				%d
 
 
 # JNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
 # JNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
 0	string			\x8bJNG		JNG video data,
 0	string			\x8bJNG		JNG video data,
 !:mime	video/x-jng
 !:mime	video/x-jng
 >4	belong			!0x0d0a1a0a	CORRUPTED,
 >4	belong			!0x0d0a1a0a	CORRUPTED,
 >4	belong			0x0d0a1a0a
 >4	belong			0x0d0a1a0a
->>16    belong	x				%ld x
->>20    belong	x				%ld
+>>16    belong	x				%d x
+>>20    belong	x				%d
 
 
 # Vivo video (Wolfram Kleff)
 # Vivo video (Wolfram Kleff)
 3	string		\x0D\x0AVersion:Vivo	Vivo video data
 3	string		\x0D\x0AVersion:Vivo	Vivo video data

+ 5 - 5
magic/Magdir/apple

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: apple,v 1.27 2013/03/09 22:36:00 christos Exp $
+# $File: apple,v 1.29 2014/04/30 21:41:02 christos Exp $
 # apple:  file(1) magic for Apple file formats
 # apple:  file(1) magic for Apple file formats
 #
 #
 0	search/1/t	FiLeStArTfIlEsTaRt	binscii (apple ][) text
 0	search/1/t	FiLeStArTfIlEsTaRt	binscii (apple ][) text
@@ -204,15 +204,15 @@
 #  purposes in YellowStep/Cocoa, including some nib files.
 #  purposes in YellowStep/Cocoa, including some nib files.
 # From: David Remahl <dremahl@apple.com>
 # From: David Remahl <dremahl@apple.com>
 2		string		typedstream	NeXT/Apple typedstream data, big endian
 2		string		typedstream	NeXT/Apple typedstream data, big endian
->0		byte		x		\b, version %hhd
+>0		byte		x		\b, version %d
 >0		byte		<5		\b
 >0		byte		<5		\b
 >>13	byte		0x81	\b
 >>13	byte		0x81	\b
->>>14	ubeshort	x		\b, system %hd
+>>>14	ubeshort	x		\b, system %d
 2		string		streamtyped NeXT/Apple typedstream data, little endian
 2		string		streamtyped NeXT/Apple typedstream data, little endian
->0		byte		x		\b, version %hhd
+>0		byte		x		\b, version %d
 >0		byte		<5		\b
 >0		byte		<5		\b
 >>13	byte		0x81	\b
 >>13	byte		0x81	\b
->>>14	uleshort	x		\b, system %hd
+>>>14	uleshort	x		\b, system %d
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 # CAF: Apple CoreAudio File Format
 # CAF: Apple CoreAudio File Format

+ 70 - 6
magic/Magdir/archive

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: archive,v 1.82 2014/03/14 18:47:29 christos Exp $
+# $File: archive,v 1.87 2014/06/03 19:15:58 christos Exp $
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 #           extracting compressed archives)
 #           extracting compressed archives)
 #
 #
@@ -93,9 +93,9 @@
 #
 #
 0	string		=!<arch>\ndebian
 0	string		=!<arch>\ndebian
 >8	string		debian-split	part of multipart Debian package
 >8	string		debian-split	part of multipart Debian package
-!:mime	application/x-debian-package
+!:mime	application/vnd.debian.binary-package
 >8	string		debian-binary	Debian binary package
 >8	string		debian-binary	Debian binary package
-!:mime	application/x-debian-package
+!:mime	application/vnd.debian.binary-package
 >8	string		!debian
 >8	string		!debian
 >68	string		>\0		(format %s)
 >68	string		>\0		(format %s)
 # These next two lines do not work, because a bzip2 Debian archive
 # These next two lines do not work, because a bzip2 Debian archive
@@ -269,7 +269,7 @@
 >9	string	\0
 >9	string	\0
 >>0	string	KWAJ
 >>0	string	KWAJ
 >>>7	string	\321\003	MS Compress archive data
 >>>7	string	\321\003	MS Compress archive data
->>>>14	ulong	>0		\b, original size: %ld bytes
+>>>>14	ulong	>0		\b, original size: %d bytes
 >>>>18		ubyte	>0x65
 >>>>18		ubyte	>0x65
 >>>>>18		string	x       \b, was %.8s
 >>>>>18		string	x       \b, was %.8s
 >>>>>(10.b-4)	string	x       \b.%.3s
 >>>>>(10.b-4)	string	x       \b.%.3s
@@ -498,7 +498,7 @@
 # This is a really bad format. A file containing HAWAII will match this...
 # This is a really bad format. A file containing HAWAII will match this...
 #0	string		HA		HA archive data,
 #0	string		HA		HA archive data,
 #>2	leshort		=1		1 file,
 #>2	leshort		=1		1 file,
-#>2	leshort		>1		%u files,
+#>2	leshort		>1		%hu files,
 #>4	byte&0x0f	=0		first is type CPY
 #>4	byte&0x0f	=0		first is type CPY
 #>4	byte&0x0f	=1		first is type ASC
 #>4	byte&0x0f	=1		first is type ASC
 #>4	byte&0x0f	=2		first is type HSC
 #>4	byte&0x0f	=2		first is type HSC
@@ -874,7 +874,7 @@
 # From: Dirk Jagdmann <doj@cubic.org>
 # From: Dirk Jagdmann <doj@cubic.org>
 # xar archive format: http://code.google.com/p/xar/
 # xar archive format: http://code.google.com/p/xar/
 0	string	xar!		xar archive
 0	string	xar!		xar archive
->6	beshort	x		- version %ld
+>6	beshort	x		- version %d
 
 
 # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
 # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
 # .kgb
 # .kgb
@@ -921,3 +921,67 @@
 >36	byte	16		\b, back-to-front
 >36	byte	16		\b, back-to-front
 >42	beshort	x		\b, (%dx,
 >42	beshort	x		\b, (%dx,
 >44	beshort	x		%d)
 >44	beshort	x		%d)
+
+# Symantec GHOST image by Joerg Jenderek at May 2014
+# http://us.norton.com/ghost/
+# http://www.garykessler.net/library/file_sigs.html
+0		ubelong&0xFFFFf7f0	0xFEEF0100	Norton GHost image
+# *.GHO
+>2		ubyte&0x08		0x00		\b, first file
+# *.GHS or *.[0-9] with cns program option
+>2		ubyte&0x08		0x08		\b, split file
+# part of split index interesting for *.ghs
+>>4		ubyte			x		id=0x%x
+# compression tag minus one equals numeric compression command line switch z[1-9]
+>3		ubyte			0		\b, no compression
+>3		ubyte			2		\b, fast compression (Z1)
+>3		ubyte			3		\b, medium compression (Z2)
+>3		ubyte			>3		
+>>3		ubyte			<11		\b, compression (Z%d-1)
+>2		ubyte&0x08		0x00		
+# ~ 30 byte password field only for *.gho
+>>12		ubequad			!0		\b, password protected
+>>44		ubyte			!1		
+# 1~Image All, sector-by-sector only for *.gho
+>>>10		ubyte			1		\b, sector copy
+# 1~Image Boot track only for *.gho
+>>>43		ubyte			1		\b, boot track
+# 1~Image Disc only for *.gho implies Image Boot track and sector copy
+>>44		ubyte			1		\b, disc sector copy
+# optional image description only *.gho
+>>0xff		string			>\0		"%-.254s"
+# look for DOS sector end sequence
+>0xE08	search/7776		\x55\xAA	
+>>&-512	indirect		x		\b; contains 
+
+# Symantec GHOST image by Joerg Jenderek at May 2014
+# http://us.norton.com/ghost/
+# http://www.garykessler.net/library/file_sigs.html
+0		ubelong&0xFFFFf7f0	0xFEEF0100	Norton GHost image
+# *.GHO
+>2		ubyte&0x08		0x00		\b, first file
+# *.GHS or *.[0-9] with cns program option
+>2		ubyte&0x08		0x08		\b, split file
+# part of split index interesting for *.ghs
+>>4		ubyte			x		id=0x%x
+# compression tag minus one equals numeric compression command line switch z[1-9]
+>3		ubyte			0		\b, no compression
+>3		ubyte			2		\b, fast compression (Z1)
+>3		ubyte			3		\b, medium compression (Z2)
+>3		ubyte			>3		
+>>3		ubyte			<11		\b, compression (Z%d-1)
+>2		ubyte&0x08		0x00		
+# ~ 30 byte password field only for *.gho
+>>12		ubequad			!0		\b, password protected
+>>44		ubyte			!1		
+# 1~Image All, sector-by-sector only for *.gho
+>>>10		ubyte			1		\b, sector copy
+# 1~Image Boot track only for *.gho
+>>>43		ubyte			1		\b, boot track
+# 1~Image Disc only for *.gho implies Image Boot track and sector copy
+>>44		ubyte			1		\b, disc sector copy
+# optional image description only *.gho
+>>0xff		string			>\0		"%-.254s"
+# look for DOS sector end sequence
+>0xE08	search/7776		\x55\xAA	
+>>&-512	indirect		x		\b; contains 

+ 5 - 5
magic/Magdir/att3b

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: att3b,v 1.8 2009/09/19 16:28:08 christos Exp $
+# $File: att3b,v 1.9 2014/04/30 21:41:02 christos Exp $
 # att3b:  file(1) magic for AT&T 3B machines
 # att3b:  file(1) magic for AT&T 3B machines
 #
 #
 # The `versions' should be un-commented if they work for you.
 # The `versions' should be un-commented if they work for you.
@@ -11,10 +11,10 @@
 # The 3B20 conflicts with SCCS.
 # The 3B20 conflicts with SCCS.
 #0	beshort		0550		3b20 COFF executable
 #0	beshort		0550		3b20 COFF executable
 #>12	belong		>0		not stripped
 #>12	belong		>0		not stripped
-#>22	beshort		>0		- version %ld
+#>22	beshort		>0		- version %d
 #0	beshort		0551		3b20 COFF executable (TV)
 #0	beshort		0551		3b20 COFF executable (TV)
 #>12	belong		>0		not stripped
 #>12	belong		>0		not stripped
-#>22	beshort		>0		- version %ld
+#>22	beshort		>0		- version %d
 #
 #
 # WE32K
 # WE32K
 #
 #
@@ -29,12 +29,12 @@
 >20	beshort		0410		(pure)
 >20	beshort		0410		(pure)
 >20	beshort		0413		(demand paged)
 >20	beshort		0413		(demand paged)
 >20	beshort		0443		(target shared library)
 >20	beshort		0443		(target shared library)
->22	beshort		>0		- version %ld
+>22	beshort		>0		- version %d
 0	beshort		0561		WE32000 COFF executable (TV)
 0	beshort		0561		WE32000 COFF executable (TV)
 >12	belong		>0		not stripped
 >12	belong		>0		not stripped
 #>18	beshort		&00020000	- 32100 required
 #>18	beshort		&00020000	- 32100 required
 #>18	beshort		&00040000	and MAU hardware required
 #>18	beshort		&00040000	and MAU hardware required
-#>22	beshort		>0		- version %ld
+#>22	beshort		>0		- version %d
 #
 #
 # core file for 3b2 
 # core file for 3b2 
 0	string		\000\004\036\212\200	3b2 core file
 0	string		\000\004\036\212\200	3b2 core file

+ 3 - 3
magic/Magdir/audio

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: audio,v 1.68 2013/12/02 13:32:26 christos Exp $
+# $File: audio,v 1.71 2014/05/14 23:30:28 christos Exp $
 # audio:  file(1) magic for sound formats (see also "iff")
 # audio:  file(1) magic for sound formats (see also "iff")
 #
 #
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
@@ -104,7 +104,7 @@
 
 
 # first entry is also the string "NTRK"
 # first entry is also the string "NTRK"
 0	belong		0x4e54524b	MultiTrack sound data
 0	belong		0x4e54524b	MultiTrack sound data
->4	belong		x		- version %ld
+>4	belong		x		- version %d
 
 
 # Extended MOD format (*.emd) (Greg Roelofs, newt@uchicago.edu); NOT TESTED
 # Extended MOD format (*.emd) (Greg Roelofs, newt@uchicago.edu); NOT TESTED
 # [based on posting 940824 by "Dirk/Elastik", husberg@lehtori.cc.tut.fi]
 # [based on posting 940824 by "Dirk/Elastik", husberg@lehtori.cc.tut.fi]
@@ -638,7 +638,7 @@
 # From: Mike Melanson <mike@multimedia.cx>
 # From: Mike Melanson <mike@multimedia.cx>
 0	string	wvpk	WavPack Lossless Audio
 0	string	wvpk	WavPack Lossless Audio
 
 
-# From Fábio R. Schmidlin <frs@pop.com.br>
+# From Fabio R. Schmidlin <frs@pop.com.br>
 # VGM music file
 # VGM music file
 0	string		Vgm\ 
 0	string		Vgm\ 
 >9	ubyte		>0	VGM Video Game Music dump v
 >9	ubyte		>0	VGM Video Game Music dump v

+ 2 - 2
magic/Magdir/bflt

@@ -1,12 +1,12 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: bflt,v 1.4 2009/09/19 16:28:08 christos Exp $
+# $File: bflt,v 1.5 2014/04/30 21:41:02 christos Exp $
 # bFLT: file(1) magic for BFLT uclinux binary files
 # bFLT: file(1) magic for BFLT uclinux binary files
 #
 #
 # From Philippe De Muyter <phdm@macqel.be>
 # From Philippe De Muyter <phdm@macqel.be>
 #
 #
 0	string		bFLT		BFLT executable
 0	string		bFLT		BFLT executable
->4	belong		x		- version %ld
+>4	belong		x		- version %d
 >4	belong		4
 >4	belong		4
 >>36	belong&0x1	0x1		ram
 >>36	belong&0x1	0x1		ram
 >>36	belong&0x2	0x2		gotpic
 >>36	belong&0x2	0x2		gotpic

+ 4 - 4
magic/Magdir/bsdi

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: bsdi,v 1.6 2013/01/09 22:37:24 christos Exp $
+# $File: bsdi,v 1.7 2014/03/29 15:40:34 christos Exp $
 # bsdi:  file(1) magic for BSD/OS (from BSDI) objects
 # bsdi:  file(1) magic for BSD/OS (from BSDI) objects
 # Some object/executable formats use the same magic numbers as are used
 # Some object/executable formats use the same magic numbers as are used
 # in other OSes; those are handled by entries in aout.
 # in other OSes; those are handled by entries in aout.
@@ -11,7 +11,7 @@
 >32	byte		0x6a		(uses shared libs)
 >32	byte		0x6a		(uses shared libs)
 
 
 # same as in SunOS 4.x, except for static shared libraries
 # same as in SunOS 4.x, except for static shared libraries
-0	belong&077777777	0600413		sparc demand paged
+0	belong&077777777	0600413		SPARC demand paged
 >0	byte		&0x80
 >0	byte		&0x80
 >>20	belong		<4096		shared library
 >>20	belong		<4096		shared library
 >>20	belong		=4096		dynamically linked executable
 >>20	belong		=4096		dynamically linked executable
@@ -20,13 +20,13 @@
 >16	belong		>0		not stripped
 >16	belong		>0		not stripped
 >36	belong		0xb4100001	(uses shared libs)
 >36	belong		0xb4100001	(uses shared libs)
 
 
-0	belong&077777777	0600410		sparc pure
+0	belong&077777777	0600410		SPARC pure
 >0	byte		&0x80		dynamically linked executable
 >0	byte		&0x80		dynamically linked executable
 >0	byte		^0x80		executable
 >0	byte		^0x80		executable
 >16	belong		>0		not stripped
 >16	belong		>0		not stripped
 >36	belong		0xb4100001	(uses shared libs)
 >36	belong		0xb4100001	(uses shared libs)
 
 
-0	belong&077777777	0600407		sparc
+0	belong&077777777	0600407		SPARC
 >0	byte		&0x80		dynamically linked executable
 >0	byte		&0x80		dynamically linked executable
 >0	byte		^0x80		executable
 >0	byte		^0x80		executable
 >16	belong		>0		not stripped
 >16	belong		>0		not stripped

+ 2 - 2
magic/Magdir/c-lang

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: c-lang,v 1.18 2013/08/14 13:06:43 christos Exp $
+# $File: c-lang,v 1.19 2014/06/03 19:17:27 christos Exp $
 # c-lang:  file(1) magic for C and related languages programs
 # c-lang:  file(1) magic for C and related languages programs
 #
 #
 
 
@@ -50,7 +50,7 @@
 >7	string		x		version %.2s
 >7	string		x		version %.2s
 # We skip the path here, because it is often long (so file will
 # We skip the path here, because it is often long (so file will
 # truncate it) and mostly redundant.
 # truncate it) and mostly redundant.
-# The inverted index functionality was added some time betwen
+# The inverted index functionality was added some time between
 # versions 11 and 15, so look for -q if version is above 14:
 # versions 11 and 15, so look for -q if version is above 14:
 >7	string		>14
 >7	string		>14
 >>10	search/100	\ -q\ 		with inverted index
 >>10	search/100	\ -q\ 		with inverted index

+ 2 - 2
magic/Magdir/cafebabe

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: cafebabe,v 1.15 2014/03/14 18:47:29 christos Exp $
+# $File: cafebabe,v 1.16 2014/04/30 21:41:02 christos Exp $
 # Cafe Babes unite!
 # Cafe Babes unite!
 #
 #
 # Since Java bytecode and Mach-O universal binaries have the same magic number,
 # Since Java bytecode and Mach-O universal binaries have the same magic number,
@@ -52,7 +52,7 @@
 >4	belong		1		Mach-O universal binary with 1 architecture:
 >4	belong		1		Mach-O universal binary with 1 architecture:
 >>8	use		mach-o		\b
 >>8	use		mach-o		\b
 >4	belong		>1
 >4	belong		>1
->>4	belong		<20		Mach-O universal binary with %ld architectures:
+>>4	belong		<20		Mach-O universal binary with %d architectures:
 >>>8	use		mach-o		\b
 >>>8	use		mach-o		\b
 >>>28	use		mach-o		\b
 >>>28	use		mach-o		\b
 >>4	belong		>2
 >>4	belong		>2

+ 2 - 2
magic/Magdir/clarion

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: clarion,v 1.4 2009/09/19 16:28:08 christos Exp $
+# $File: clarion,v 1.5 2014/04/30 21:41:02 christos Exp $
 # clarion:  file(1) magic for # Clarion Personal/Professional Developer
 # clarion:  file(1) magic for # Clarion Personal/Professional Developer
 # (v2 and above)
 # (v2 and above)
 # From: Julien Blache <jb@jblache.org>
 # From: Julien Blache <jb@jblache.org>
@@ -15,7 +15,7 @@
 >2	leshort	&0x0010	\b, compressed
 >2	leshort	&0x0010	\b, compressed
 >2	leshort	&0x0040	\b, read only
 >2	leshort	&0x0040	\b, read only
 # number of records
 # number of records
->5	lelong	x	\b, %ld records
+>5	lelong	x	\b, %d records
 
 
 # Memo files
 # Memo files
 0	leshort	0x334d	Clarion Developer (v2 and above) memo data
 0	leshort	0x334d	Clarion Developer (v2 and above) memo data

+ 2 - 2
magic/Magdir/claris

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: claris,v 1.6 2012/06/20 21:19:05 christos Exp $
+# $File: claris,v 1.7 2014/06/03 19:17:27 christos Exp $
 # claris:  file(1) magic for claris
 # claris:  file(1) magic for claris
 # "H. Nanosecond" <aldomel@ix.netcom.com>
 # "H. Nanosecond" <aldomel@ix.netcom.com>
 # Claris Works a word processor, etc.
 # Claris Works a word processor, etc.
@@ -20,7 +20,7 @@
 # .cwk
 # .cwk
 0	string	\002\000\210\003\102\117\102\117\000\001\206 Claris works document
 0	string	\002\000\210\003\102\117\102\117\000\001\206 Claris works document
 # .plt
 # .plt
-0	string	\020\341\000\000\010\010	Claris Works pallete files .plt
+0	string	\020\341\000\000\010\010	Claris Works palette files .plt
 
 
 # .msp a dictionary file I am not sure about this I have only one .msp file
 # .msp a dictionary file I am not sure about this I have only one .msp file
 0	string	\002\271\262\000\040\002\000\164	Claris works dictionary
 0	string	\002\271\262\000\040\002\000\164	Claris works dictionary

+ 3 - 3
magic/Magdir/clipper

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: clipper,v 1.6 2009/09/19 16:28:08 christos Exp $
+# $File: clipper,v 1.7 2014/04/30 21:41:02 christos Exp $
 # clipper:  file(1) magic for Intergraph (formerly Fairchild) Clipper.
 # clipper:  file(1) magic for Intergraph (formerly Fairchild) Clipper.
 #
 #
 # XXX - what byte order does the Clipper use?
 # XXX - what byte order does the Clipper use?
@@ -35,7 +35,7 @@
 >20	short		0413		(demand paged)
 >20	short		0413		(demand paged)
 >20	short		0443		(target shared library)
 >20	short		0443		(target shared library)
 >12	long		>0		not stripped
 >12	long		>0		not stripped
->22	short		>0		- version %ld
+>22	short		>0		- version %d
 0	short		0577		CLIPPER COFF executable
 0	short		0577		CLIPPER COFF executable
 >18	short&074000	000000		C1 R1 
 >18	short&074000	000000		C1 R1 
 >18	short&074000	004000		C2 R1
 >18	short&074000	004000		C2 R1
@@ -47,7 +47,7 @@
 >20	short		0413		(paged)
 >20	short		0413		(paged)
 >20	short		0443		(target shared library)
 >20	short		0443		(target shared library)
 >12	long		>0		not stripped
 >12	long		>0		not stripped
->22	short		>0		- version %ld
+>22	short		>0		- version %d
 >48	long&01		01		alignment trap enabled
 >48	long&01		01		alignment trap enabled
 >52	byte		1		-Ctnc
 >52	byte		1		-Ctnc
 >52	byte		2		-Ctsw
 >52	byte		2		-Ctsw

+ 2 - 2
magic/Magdir/commands

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: commands,v 1.48 2014/03/04 12:20:42 kim Exp $
+# $File: commands,v 1.50 2014/05/30 16:48:44 christos Exp $
 # commands:  file(1) magic for various shells and interpreters
 # commands:  file(1) magic for various shells and interpreters
 #
 #
 #0	string/w	:			shell archive or script for antique kernel text
 #0	string/w	:			shell archive or script for antique kernel text
@@ -56,7 +56,7 @@
 !:mime	text/x-awk
 !:mime	text/x-awk
 0	string/wt	#!\ /usr/bin/awk	awk script text executable
 0	string/wt	#!\ /usr/bin/awk	awk script text executable
 !:mime	text/x-awk
 !:mime	text/x-awk
-0	regex		=^\\s{0,100}BEGIN\\s{0,100}[{]	awk script text
+0	regex/4096	=^\\s{0,100}BEGIN\\s{0,100}[{]	awk script text
 
 
 # AT&T Bell Labs' Plan 9 shell
 # AT&T Bell Labs' Plan 9 shell
 0	string/wt	#!\ /bin/rc	Plan 9 rc shell script text executable
 0	string/wt	#!\ /bin/rc	Plan 9 rc shell script text executable

+ 10 - 3
magic/Magdir/compress

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: compress,v 1.54 2014/03/14 18:47:29 christos Exp $
+# $File: compress,v 1.58 2014/05/07 19:36:59 christos Exp $
 # compress:  file(1) magic for pure-compression formats (no archives)
 # compress:  file(1) magic for pure-compression formats (no archives)
 #
 #
 # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
 # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@@ -210,9 +210,12 @@
 !:mime	application/x-lrzip
 !:mime	application/x-lrzip
 
 
 # http://fastcompression.blogspot.fi/2013/04/lz4-streaming-format-final.html
 # http://fastcompression.blogspot.fi/2013/04/lz4-streaming-format-final.html
-0	lelong		0x184d2204	LZ4 compressed data
+0	lelong		0x184d2204	LZ4 compressed data (v1.4+)
 !:mime	application/x-lz4
 !:mime	application/x-lz4
-0	lelong		0x184c2102	LZ4 compressed data, legacy format
+# Added by osm0sis@xda-developers.com
+0 	lelong		0x184c2103	LZ4 compressed data (v1.0-v1.3)
+!:mime	application/x-lz4
+0	lelong		0x184c2102	LZ4 compressed data (v0.1-v0.9)
 !:mime	application/x-lz4
 !:mime	application/x-lz4
 
 
 # AFX compressed files (Wolfram Kleff)
 # AFX compressed files (Wolfram Kleff)
@@ -244,3 +247,7 @@
 >0x4	lelong	x		\b, version %u
 >0x4	lelong	x		\b, version %u
 >0x8	lelong	x		\b, %u entries
 >0x8	lelong	x		\b, %u entries
 
 
+# Snappy framing format
+# http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
+0	string	\377\006\0\0sNaPpY	snappy framed data
+!:mime	application/x-snappy-framed

+ 4 - 4
magic/Magdir/cups

@@ -1,12 +1,12 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: cups,v 1.2 2012/11/02 21:50:29 christos Exp $
+# $File: cups,v 1.3 2014/05/28 19:50:41 christos Exp $
 # Cups: file(1) magic for the cups raster file format
 # Cups: file(1) magic for the cups raster file format
 # From: Laurent Martelli <martellilaurent@gmail.com>
 # From: Laurent Martelli <martellilaurent@gmail.com>
 # http://www.cups.org/documentation.php/spec-raster.html
 # http://www.cups.org/documentation.php/spec-raster.html
 #
 #
 
 
-0	name		cups-be
+0	name		cups-le
 >280	lelong		x		\b, %d
 >280	lelong		x		\b, %d
 >284	lelong		x		\bx%d dpi
 >284	lelong		x		\bx%d dpi
 >376	lelong		x		\b, %dx
 >376	lelong		x		\b, %dx
@@ -44,7 +44,7 @@
 >3	string		2		Cups Raster version 2, Big Endian
 >3	string		2		Cups Raster version 2, Big Endian
 >3	string		3		Cups Raster version 3, Big Endian
 >3	string		3		Cups Raster version 3, Big Endian
 !:mime	application/vnd.cups-raster
 !:mime	application/vnd.cups-raster
->0	use		^cups-be
+>0	use		^cups-le
 
 
 
 
 # Cups Raster image format, Little Endian
 # Cups Raster image format, Little Endian
@@ -53,4 +53,4 @@
 >0	string		2		Cups Raster version 2, Little Endian
 >0	string		2		Cups Raster version 2, Little Endian
 >0	string		3		Cups Raster version 3, Little Endian
 >0	string		3		Cups Raster version 3, Little Endian
 !:mime	application/vnd.cups-raster
 !:mime	application/vnd.cups-raster
->0	use		\^cups-be
+>0	use		cups-le

+ 11 - 11
magic/Magdir/database

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: database,v 1.37 2014/03/14 18:47:29 christos Exp $
+# $File: database,v 1.41 2014/06/03 19:17:27 christos Exp $
 # database:  file(1) magic for various databases
 # database:  file(1) magic for various databases
 #
 #
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@@ -105,7 +105,7 @@
 >>8	quad		0		64bit aligned
 >>8	quad		0		64bit aligned
 >>>16	bedouble	8.642135e+130	big-endian
 >>>16	bedouble	8.642135e+130	big-endian
 >>>>24	long		0		64bit long (s390x)
 >>>>24	long		0		64bit long (s390x)
->>>>24	long		!0		32bit long (hppa/mips/ppc/s390/sparc)
+>>>>24	long		!0		32bit long (hppa/mips/ppc/s390/SPARC)
 >>>16	ledouble	8.642135e+130	little-endian
 >>>16	ledouble	8.642135e+130	little-endian
 >>>>28	long		0		64bit long (alpha/amd64/ia64)
 >>>>28	long		0		64bit long (alpha/amd64/ia64)
 >>>>28	long		!0		32bit long (armel/mipsel)
 >>>>28	long		!0		32bit long (armel/mipsel)
@@ -176,7 +176,7 @@
 # database file
 # database file
 >>>>>>>>>>>>0	ubyte			x		\b DBF
 >>>>>>>>>>>>0	ubyte			x		\b DBF
 >>>>>>>>>>>>4	lelong			0		\b, no records
 >>>>>>>>>>>>4	lelong			0		\b, no records
->>>>>>>>>>>>4	lelong			>0		\b, %ld record
+>>>>>>>>>>>>4	lelong			>0		\b, %d record
 # plural s appended
 # plural s appended
 >>>>>>>>>>>>>4	lelong			>1		\bs
 >>>>>>>>>>>>>4	lelong			>1		\bs
 # http://www.clicketyclick.dk/databases/xbase/format/dbf_check.html#CHECK_DBF
 # http://www.clicketyclick.dk/databases/xbase/format/dbf_check.html#CHECK_DBF
@@ -364,22 +364,22 @@
 >>16	ubyte			0		
 >>16	ubyte			0		
 >>>512	ubelong			<0x00000003	FoxPro FPT
 >>>512	ubelong			<0x00000003	FoxPro FPT
 # Size of blocks for FoxPro
 # Size of blocks for FoxPro
->>>>6	ubeshort		x		\b, blocks size %lu
+>>>>6	ubeshort		x		\b, blocks size %u
 # Number of next available block for appending data for FoxPro
 # Number of next available block for appending data for FoxPro
->>>>0	ubelong			=0		\b, next free block index %lu
->>>>0	ubelong			!0		\b, next free block index %lu
+>>>>0	ubelong			=0		\b, next free block index %u
+>>>>0	ubelong			!0		\b, next free block index %u
 >>>512	default			x		dBase IV DBT
 >>>512	default			x		dBase IV DBT
-# DBF file name without extention 
+# DBF file name without extension
 >>>>8	string			>\0		\b of %-.8s.DBF
 >>>>8	string			>\0		\b of %-.8s.DBF
 # size of blocks  ; not reliable 0x2020204C
 # size of blocks  ; not reliable 0x2020204C
-#>>>>4	ulelong			=0		\b, blocks size %lu
->>>>4	ulelong			!0		\b, blocks size %lu
+#>>>>4	ulelong			=0		\b, blocks size %u
+>>>>4	ulelong			!0		\b, blocks size %u
 # Block length found 0 , 512
 # Block length found 0 , 512
 #>>>>20	uleshort		=0		\b, block length %u
 #>>>>20	uleshort		=0		\b, block length %u
 >>>>20	uleshort		!0		\b, block length %u
 >>>>20	uleshort		!0		\b, block length %u
 # Number of next available block for appending data
 # Number of next available block for appending data
->>>>0	ulelong			=0		\b, next free block index %lu
->>>>0	ulelong			!0		\b, next free block index %lu
+>>>>0	ulelong			=0		\b, next free block index %u
+>>>>0	ulelong			!0		\b, next free block index %u
 >>512	ubelong			x		
 >>512	ubelong			x		
 >>>512	ubelong			=0xFFFF0800	
 >>>512	ubelong			=0xFFFF0800	
 >>>>520	string			>\0		\b, 1st used item "%s"
 >>>>520	string			>\0		\b, 1st used item "%s"

+ 5 - 5
magic/Magdir/dump

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: dump,v 1.12 2012/11/01 04:26:40 christos Exp $
+# $File: dump,v 1.13 2014/04/30 21:41:02 christos Exp $
 # dump:  file(1) magic for dump file format--for new and old dump filesystems
 # dump:  file(1) magic for dump file format--for new and old dump filesystems
 #
 #
 # We specify both byte orders in order to recognize byte-swapped dumps.
 # We specify both byte orders in order to recognize byte-swapped dumps.
@@ -8,7 +8,7 @@
 0	name	new-dump-be
 0	name	new-dump-be
 >4	bedate	x		Previous dump %s,
 >4	bedate	x		Previous dump %s,
 >8	bedate	x		This dump %s,
 >8	bedate	x		This dump %s,
->12	belong	>0		Volume %ld,
+>12	belong	>0		Volume %d,
 >692	belong	0		Level zero, type:
 >692	belong	0		Level zero, type:
 >692	belong	>0		Level %d, type:
 >692	belong	>0		Level %d, type:
 >0	belong	1		tape header,
 >0	belong	1		tape header,
@@ -27,7 +27,7 @@
 0	name	old-dump-be
 0	name	old-dump-be
 #>4	bedate	x		Previous dump %s,
 #>4	bedate	x		Previous dump %s,
 #>8	bedate	x		This dump %s,
 #>8	bedate	x		This dump %s,
->12	belong	>0		Volume %ld,
+>12	belong	>0		Volume %d,
 >692	belong	0		Level zero, type:
 >692	belong	0		Level zero, type:
 >692	belong	>0		Level %d, type:
 >692	belong	>0		Level %d, type:
 >0	belong	1		tape header,
 >0	belong	1		tape header,
@@ -46,7 +46,7 @@
 0	name	ufs2-dump-be
 0	name	ufs2-dump-be
 >896	beqdate	x		Previous dump %s,
 >896	beqdate	x		Previous dump %s,
 >904	beqdate	x		This dump %s,
 >904	beqdate	x		This dump %s,
->12	belong	>0		Volume %ld,
+>12	belong	>0		Volume %d,
 >692	belong	0		Level zero, type:
 >692	belong	0		Level zero, type:
 >692	belong	>0		Level %d, type:
 >692	belong	>0		Level %d, type:
 >0	belong	1		tape header,
 >0	belong	1		tape header,
@@ -84,7 +84,7 @@
 18	leshort	60011		old-fs dump file (16-bit, assuming PDP-11 endianness),
 18	leshort	60011		old-fs dump file (16-bit, assuming PDP-11 endianness),
 >2	medate	x		Previous dump %s,
 >2	medate	x		Previous dump %s,
 >6	medate	x		This dump %s,
 >6	medate	x		This dump %s,
->10	leshort	>0		Volume %ld,
+>10	leshort	>0		Volume %d,
 >0	leshort	1		tape header.
 >0	leshort	1		tape header.
 >0	leshort	2		beginning of file record.
 >0	leshort	2		beginning of file record.
 >0	leshort	3		map of inodes on tape.
 >0	leshort	3		map of inodes on tape.

+ 50 - 40
magic/Magdir/dyadic

@@ -1,46 +1,56 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: dyadic,v 1.5 2010/09/20 18:55:20 rrt Exp $
+# $File: dyadic,v 1.6 2014/06/01 19:14:42 christos Exp $
 # Dyadic: file(1) magic for Dyalog APL.
 # Dyadic: file(1) magic for Dyalog APL.
 #
 #
-0	byte	0xaa
->1	byte	<4		Dyalog APL
->>1	byte	0x00		incomplete workspace
->>1	byte	0x01		component file
->>1	byte	0x02		external variable
->>1	byte	0x03		workspace
->>2	byte	x		version %d
->>3	byte	x		.%d
-
-0	beshort		0xaa03		Dyalog APL
->2	byte		x		workspace type %d
->3	byte		x		subtype %d
->7	byte&0x28	0x00		32-bit
->7	byte&0x28	0x20		64-bit
->7	byte&0x0c	0x00		classic
->7	byte&0x0c	0x04		unicode
->7	byte&0x88	0x00		big-endian
->7	byte&0x88	0x80		little-endian
-
-0	byte		0xaa		Dyalog APL
->1	byte		0x00		aplcore
->1	byte		0x01		component file 32-bit non-journaled non-checksummed
->1	byte		0x02		external variable exclusive
->1	byte		0x06		external variable shared
->1	byte		0x07		session
->1	byte		0x08		mapped file 32-bit
->1	byte		0x09		component file 64-bit non-journaled non-checksummed
->1	byte		0x0a		mapped file 64-bit
->1	byte		0x0b		component file 32-bit level 1 journaled non-checksummed
->1	byte		0x0c		component file 64-bit level 1 journaled non-checksummed
->1	byte		0x0d		component file 32-bit level 1 journaled checksummed
->1	byte		0x0e		component file 64-bit level 1 journaled checksummed
->1	byte		0x0f		component file 32-bit level 2 journaled checksummed
->1	byte		0x10		component file 64-bit level 2 journaled checksummed
->1	byte		0x11		component file 32-bit level 3 journaled checksummed
->1	byte		0x12		component file 64-bit level 3 journaled checksummed
->1	byte		0x13		component file 32-bit non-journaled checksummed
->1	byte		0x14		component file 64-bit non-journaled checksummed
->1	byte		0x80		DDB
+# updated by Joerg Jenderek at Oct 2013
+# http://en.wikipedia.org/wiki/Dyalog_APL
+# http://www.dyalog.com/
+# .DXV Dyalog APL External Variable
+# .DIN Dyalog APL Input Table
+# .DOT Dyalog APL Output Table
+# .DFT Dyalog APL Format File
+0	ubeshort&0xFF60	0xaa00		
+# skip biblio.dbt
+>1	byte		!4		
+# real Dyalog APL have non zero version numbers like 7.3 or 13.4
+>>2	ubeshort	>0x0000		Dyalog APL
+>>>1	byte		0x00		aplcore
+#>>>1	byte		0x00		incomplete workspace
+# *.DCF Dyalog APL Component File
+>>>1	byte		0x01		component file 32-bit non-journaled non-checksummed
+#>>>1	byte		0x01		component file
+>>>1	byte		0x02		external variable exclusive
+#>>>1	byte		0x02		external variable
+# *.DWS Dyalog APL Workspace
+>>>1	byte		0x03		workspace
+>>>>7	byte&0x28	0x00		32-bit
+>>>>7	byte&0x28	0x20		64-bit
+>>>>7	byte&0x0c	0x00		classic
+>>>>7	byte&0x0c	0x04		unicode
+>>>>7	byte&0x88	0x00		big-endian
+>>>>7	byte&0x88	0x80		little-endian
+>>>1	byte		0x06		external variable shared
+# *.DSE Dyalog APL Session , *.DLF Dyalog APL Session Log File
+>>>1	byte		0x07		session
+>>>1	byte		0x08		mapped file 32-bit
+>>>1	byte		0x09		component file 64-bit non-journaled non-checksummed
+>>>1	byte		0x0a		mapped file 64-bit
+>>>1	byte		0x0b		component file 32-bit level 1 journaled non-checksummed
+>>>1	byte		0x0c		component file 64-bit level 1 journaled non-checksummed
+>>>1	byte		0x0d		component file 32-bit level 1 journaled checksummed
+>>>1	byte		0x0e		component file 64-bit level 1 journaled checksummed
+>>>1	byte		0x0f		component file 32-bit level 2 journaled checksummed
+>>>1	byte		0x10		component file 64-bit level 2 journaled checksummed
+>>>1	byte		0x11		component file 32-bit level 3 journaled checksummed
+>>>1	byte		0x12		component file 64-bit level 3 journaled checksummed
+>>>1	byte		0x13		component file 32-bit non-journaled checksummed
+>>>1	byte		0x14		component file 64-bit non-journaled checksummed
+>>>1	byte		0x80		DDB
+>>>2	byte		x		version %d
+>>>3	byte		x		\b.%d
+#>>>2	byte		x		type %d
+#>>>3	byte		x		subtype %d
 
 
+# *.DXF Dyalog APL Transfer File
 0	short		0x6060		Dyalog APL transfer
 0	short		0x6060		Dyalog APL transfer

+ 2 - 2
magic/Magdir/efi

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: efi,v 1.4 2009/09/19 16:28:09 christos Exp $
+# $File: efi,v 1.5 2014/04/30 21:41:02 christos Exp $
 # efi:  file(1) magic for Universal EFI binaries
 # efi:  file(1) magic for Universal EFI binaries
 
 
 0	lelong	0x0ef1fab9
 0	lelong	0x0ef1fab9
@@ -12,4 +12,4 @@
 >>&0	lelong	0x01000007	\b, x86_64
 >>&0	lelong	0x01000007	\b, x86_64
 >>&20	lelong	7		\b, i386
 >>&20	lelong	7		\b, i386
 >>&20	lelong	0x01000007	\b, x86_64
 >>&20	lelong	0x01000007	\b, x86_64
->4	lelong	>2		Universal EFI binary with %ld architectures
+>4	lelong	>2		Universal EFI binary with %d architectures

+ 15 - 1
magic/Magdir/elf

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: elf,v 1.66 2014/03/06 16:37:39 christos Exp $
+# $File: elf,v 1.67 2014/06/12 13:52:48 christos Exp $
 # elf:  file(1) magic for ELF executables
 # elf:  file(1) magic for ELF executables
 #
 #
 # We have to check the byte order flag to see what byte order all the
 # We have to check the byte order flag to see what byte order all the
@@ -243,6 +243,20 @@
 >18	leshort		191		Tilera TILE-Gx,
 >18	leshort		191		Tilera TILE-Gx,
 >18	leshort		197		Renesas RL78 family,
 >18	leshort		197		Renesas RL78 family,
 >18	leshort		199		Renesas 78K0R,
 >18	leshort		199		Renesas 78K0R,
+>18	leshort		200		Freescale 56800EX,
+>18	leshort		201		Beyond BA1,
+>18	leshort		202		Beyond BA2,
+>18	leshort		203		XMOS xCORE,
+>18	leshort		204		Microchip 8-bit PIC(r),
+>18	leshort		210		KM211 KM32,
+>18	leshort		211		KM211 KMX32,
+>18	leshort		212		KM211 KMX16,
+>18	leshort		213		KM211 KMX8,
+>18	leshort		214		KM211 KVARC,
+>18	leshort		215		Paneve CDP,
+>18	leshort		216		Cognitive Smart Memory,
+>18	leshort		217		iCelero CoolEngine,
+>18	leshort		218		Nanoradio Optimized RISC,
 >18	leshort		0x1057		AVR (unofficial),
 >18	leshort		0x1057		AVR (unofficial),
 >18	leshort		0x1059		MSP430 (unofficial),
 >18	leshort		0x1059		MSP430 (unofficial),
 >18	leshort		0x1223		Adapteva Epiphany (unofficial),
 >18	leshort		0x1223		Adapteva Epiphany (unofficial),

+ 3 - 3
magic/Magdir/encore

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: encore,v 1.6 2009/09/19 16:28:09 christos Exp $
+# $File: encore,v 1.7 2014/04/30 21:41:02 christos Exp $
 # encore:  file(1) magic for Encore machines
 # encore:  file(1) magic for Encore machines
 #
 #
 # XXX - needs to have the byte order specified (NS32K was little-endian,
 # XXX - needs to have the byte order specified (NS32K was little-endian,
@@ -12,11 +12,11 @@
 >20	short		0x10b		demand-paged executable
 >20	short		0x10b		demand-paged executable
 >20	short		0x10f		unsupported executable
 >20	short		0x10f		unsupported executable
 >12	long		>0		not stripped
 >12	long		>0		not stripped
->22	short		>0		- version %ld
+>22	short		>0		- version %d
 >22	short		0		-
 >22	short		0		-
 #>4	date		x		stamp %s
 #>4	date		x		stamp %s
 0	short		0x155		Encore unsupported executable
 0	short		0x155		Encore unsupported executable
 >12	long		>0		not stripped
 >12	long		>0		not stripped
->22	short		>0		- version %ld
+>22	short		>0		- version %d
 >22	short		0		-
 >22	short		0		-
 #>4	date		x		stamp %s
 #>4	date		x		stamp %s

+ 70 - 132
magic/Magdir/filesystems

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: filesystems,v 1.87 2014/03/01 03:04:06 christos Exp $
+# $File: filesystems,v 1.95 2014/06/03 19:17:27 christos Exp $
 # filesystems:  file(1) magic for different filesystems
 # filesystems:  file(1) magic for different filesystems
 #
 #
 0	name	partid  
 0	name	partid  
@@ -204,8 +204,8 @@
 >>0752	short		>0		%d alt cyls,
 >>0752	short		>0		%d alt cyls,
 >>0754	short		>0		%d heads/partition,
 >>0754	short		>0		%d heads/partition,
 >>0756	short		>0		%d sectors/track,
 >>0756	short		>0		%d sectors/track,
->>0764	long		>0		start cyl %ld,
->>0770	long		x		%ld blocks
+>>0764	long		>0		start cyl %d,
+>>0770	long		x		%d blocks
 # Is there a boot block written 1 sector in?
 # Is there a boot block written 1 sector in?
 >512    belong&077777777	0600407	\b, boot block present
 >512    belong&077777777	0600407	\b, boot block present
 
 
@@ -249,7 +249,7 @@
 0	string	PNCIUNDO		Norton Disk Doctor UnDo file
 0	string	PNCIUNDO		Norton Disk Doctor UnDo file
 #
 #
 
 
-# DOS/MBR boot sector updated by Joerg Jenderek at Sep 2007,May 2011
+# DOS/MBR boot sector updated by Joerg Jenderek at Sep 2007,May 2011,2013
 # for any allowed sector sizes
 # for any allowed sector sizes
 30		search/481	\x55\xAA	
 30		search/481	\x55\xAA	
 # to display DOS/MBR boot sector (40) before old one (strength=50+21),Syslinux bootloader (71),SYSLINUX MBR (37+36),NetBSD mbr (110),AdvanceMAME mbr (111)
 # to display DOS/MBR boot sector (40) before old one (strength=50+21),Syslinux bootloader (71),SYSLINUX MBR (37+36),NetBSD mbr (110),AdvanceMAME mbr (111)
@@ -262,10 +262,10 @@
 >0x1FE		leshort		0xAA55		DOS/MBR boot sector
 >0x1FE		leshort		0xAA55		DOS/MBR boot sector
 # keep old DOS/MBR boot sector as dummy for mbr and bootloader displaying
 # keep old DOS/MBR boot sector as dummy for mbr and bootloader displaying
 # only for sector sizes with 512 or more Bytes
 # only for sector sizes with 512 or more Bytes
-0x1FE		leshort		0xAA55		DOS/MBR boot sector
-!:strength +72
+0x1FE		leshort		0xAA55		
+#
 # to display information (50) before DOS BPB (strength=70) and after DOS floppy (120) like in old file version
 # to display information (50) before DOS BPB (strength=70) and after DOS floppy (120) like in old file version
-#!:strength +21
+!:strength +21
 >2	string	OSBS			\b, OS/BS MBR
 >2	string	OSBS			\b, OS/BS MBR
 # added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/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
 # and http://en.wikipedia.org/wiki/Master_Boot_Record
@@ -319,8 +319,8 @@
 # assembler instructions: rep;movsb;retf;mov si,07be;mov cl,04
 # assembler instructions: rep;movsb;retf;mov si,07be;mov cl,04
 >>>24		ubequad	0xf3a4cbbebe07b104		9M
 >>>24		ubequad	0xf3a4cbbebe07b104		9M
 # "Invalid partition table"				nn=0x10F for english version
 # "Invalid partition table"				nn=0x10F for english version
-# "Ungültige Partitionstabelle"				nn=0x10F for german version
-# "Table de partition erronée"				nn=0x10F for french version
+# "Ung\201ltige Partitionstabelle"				nn=0x10F for german version
+# "Table de partition erron\202e"				nn=0x10F for french version
 # "\216\257\245\340\240\346\250\256\255\255\240\357 \341\250\341\342\245\254\240 \255\245 \255\240\251\244\245\255\240"	nn=0x10F for russian version
 # "\216\257\245\340\240\346\250\256\255\255\240\357 \341\250\341\342\245\254\240 \255\245 \255\240\251\244\245\255\240"	nn=0x10F for russian version
 >>>>(0x3C.b+0x0FF)	string	Invalid\ partition\ table		english
 >>>>(0x3C.b+0x0FF)	string	Invalid\ partition\ table		english
 >>>>(0x3C.b+0x0FF)	string	Ung\201ltige\ Partitionstabelle		german
 >>>>(0x3C.b+0x0FF)	string	Ung\201ltige\ Partitionstabelle		german
@@ -330,13 +330,13 @@
 >>>>(0x3C.b+0x0FF)	string	>\0			"%s"
 >>>>(0x3C.b+0x0FF)	string	>\0			"%s"
 # "Error loading operating system"			nn=0x127 for english version
 # "Error loading operating system"			nn=0x127 for english version
 # "Fehler beim Laden des Betriebssystems"		nn=0x12b for german version
 # "Fehler beim Laden des Betriebssystems"		nn=0x12b for german version
-# "Erreur lors du chargement du système d'exploitation"	nn=0x12a for french version
+# "Erreur lors du chargement du syst\212me d'exploitation"	nn=0x12a for french version
 # "\216\350\250\241\252\240 \257\340\250 \247\240\243\340\343\247\252\245 \256\257\245\340\240\346\250\256\255\255\256\251 \341\250\341\342\245\254\353"	nn=0x12d for russian version
 # "\216\350\250\241\252\240 \257\340\250 \247\240\243\340\343\247\252\245 \256\257\245\340\240\346\250\256\255\255\256\251 \341\250\341\342\245\254\353"	nn=0x12d for russian version
 >>>>0xBD		ubyte	x			at offset 0x1%x
 >>>>0xBD		ubyte	x			at offset 0x1%x
 >>>>(0xBD.b+0x100)	string	>\0			"%s"
 >>>>(0xBD.b+0x100)	string	>\0			"%s"
 # "Missing operating system"				nn=0x146 for english version
 # "Missing operating system"				nn=0x146 for english version
 # "Betriebssystem fehlt"				nn=0x151 for german version
 # "Betriebssystem fehlt"				nn=0x151 for german version
-# "Système d'exploitation manquant"			nn=0x15e for french version
+# "Syst\212me d'exploitation manquant"			nn=0x15e for french version
 # "\216\257\245\340\240\346\250\256\255\255\240\357 \341\250\341\342\245\254\240 \255\245 \255\240\251\244\245\255\240"	nn=0x156 for russian version
 # "\216\257\245\340\240\346\250\256\255\255\240\357 \341\250\341\342\245\254\240 \255\245 \255\240\251\244\245\255\240"	nn=0x156 for russian version
 >>>>0xA9		ubyte	x			at offset 0x1%x
 >>>>0xA9		ubyte	x			at offset 0x1%x
 >>>>(0xA9.b+0x100)	string	>\0			"%s"
 >>>>(0xA9.b+0x100)	string	>\0			"%s"
@@ -347,7 +347,7 @@
 >>>>0x1B4	ubelong&0x00FFFFFF	0x002c4463	english
 >>>>0x1B4	ubelong&0x00FFFFFF	0x002c4463	english
 >>>>0x1B4	ubelong&0x00FFFFFF	0x002c486e	german
 >>>>0x1B4	ubelong&0x00FFFFFF	0x002c486e	german
 # "Invalid partition table"				xx=0x12C for english version
 # "Invalid partition table"				xx=0x12C for english version
-# "Ungültige Partitionstabelle"				xx=0x12C for german version
+# "Ung\201ltige Partitionstabelle"				xx=0x12C for german version
 >>>>0x1b5	ubyte		>0			at offset 0x1%x
 >>>>0x1b5	ubyte		>0			at offset 0x1%x
 >>>>(0x1b5.b+0x100)	string	>\0			"%s"
 >>>>(0x1b5.b+0x100)	string	>\0			"%s"
 # "Error loading operating system"			yy=0x144 for english version
 # "Error loading operating system"			yy=0x144 for english version
@@ -368,7 +368,7 @@
 >>>>0x1B4	ubelong&0x00FFFFFF	0x00627a99	english
 >>>>0x1B4	ubelong&0x00FFFFFF	0x00627a99	english
 #>>>>0x1B4	ubelong&0x00FFFFFF	?		german
 #>>>>0x1B4	ubelong&0x00FFFFFF	?		german
 # "Invalid partition table"				xx=0x162 for english version
 # "Invalid partition table"				xx=0x162 for english version
-# "Ungültige Partitionstabelle"				xx=0x1?? for german version
+# "Ung\201ltige Partitionstabelle"				xx=0x1?? for german version
 >>>>0x1b5	ubyte		>0			at offset 0x1%x
 >>>>0x1b5	ubyte		>0			at offset 0x1%x
 >>>>(0x1b5.b+0x100)	string	>\0			"%s"
 >>>>(0x1b5.b+0x100)	string	>\0			"%s"
 # "Error loading operating system"			yy=0x17a for english version
 # "Error loading operating system"			yy=0x17a for english version
@@ -386,7 +386,7 @@
 >>>>0x1B4	ubelong&0x00FFFFFF	0x00637b9a	english
 >>>>0x1B4	ubelong&0x00FFFFFF	0x00637b9a	english
 #>>>>0x1B4	ubelong&0x00FFFFFF	?		german
 #>>>>0x1B4	ubelong&0x00FFFFFF	?		german
 # "Invalid partition table"				xx=0x163 for english version
 # "Invalid partition table"				xx=0x163 for english version
-# "Ungültige Partitionstabelle"				xx=0x1?? for german version
+# "Ung\201ltige Partitionstabelle"				xx=0x1?? for german version
 >>>>0x1b5	ubyte		>0			at offset 0x1%x
 >>>>0x1b5	ubyte		>0			at offset 0x1%x
 >>>>(0x1b5.b+0x100)	string	>\0			"%s"
 >>>>(0x1b5.b+0x100)	string	>\0			"%s"
 # "Error loading operating system"			yy=0x17b for english version
 # "Error loading operating system"			yy=0x17b for english version
@@ -519,7 +519,7 @@
 >>>>>379	string	GRUB\ \0		\b, GRUB version 0.95 or 0.96
 >>>>>379	string	GRUB\ \0		\b, GRUB version 0.95 or 0.96
 >>>>391		string	Geom\0Hard\ Disk\0Read\0\ Error\0
 >>>>391		string	Geom\0Hard\ Disk\0Read\0\ Error\0
 >>>>>385	string	GRUB\ \0		\b, GRUB version 0.97
 >>>>>385	string	GRUB\ \0		\b, GRUB version 0.97
-#unkown version
+# unknown version
 >>>343		string	Geom\0Read\0\ Error\0	
 >>>343		string	Geom\0Read\0\ Error\0	
 >>>>321		string	Loading\ stage1.5	\b, GRUB version x.y
 >>>>321		string	Loading\ stage1.5	\b, GRUB version x.y
 >>>380		string	Geom\0Hard\ Disk\0Read\0\ Error\0
 >>>380		string	Geom\0Hard\ Disk\0Read\0\ Error\0
@@ -566,16 +566,11 @@
 #OEM-ID=BOOTWIZ0
 #OEM-ID=BOOTWIZ0
 >442	string	Non-system\ disk,\ 	
 >442	string	Non-system\ disk,\ 	
 >>459	string	press\ any\ key...\x7\0		\b, Acronis Startup Recovery Loader
 >>459	string	press\ any\ key...\x7\0		\b, Acronis Startup Recovery Loader
-# updated by Joerg Jenderek at Nov 2012
+# updated by Joerg Jenderek at Nov 2012, Sep 2013
 # DOS names like F11.SYS or BOOTWIZ.SYS are 8 right space padded bytes+3 bytes
 # DOS names like F11.SYS or BOOTWIZ.SYS are 8 right space padded bytes+3 bytes
->>>477		ubyte&0xDF	>0		
->>>>477		string		x 		\b %-.3s
->>>>>480	ubyte&0xDF	>0		
->>>>>>480	string		x 		\b%-.4s
->>>>>>>484	ubyte&0xDF	>0		
->>>>>>>>484	string		x 		\b%-.1s
->>>>485		ubyte&0xDF	>0		
->>>>>485	string		x 		\b.%-.3s
+# display 1 space
+>>>447	ubyte	x		\b 
+>>>477	use	DOS-filename
 #
 #
 >185	string	FDBOOT\ Version\ 			
 >185	string	FDBOOT\ Version\ 			
 >>204	string	\rNo\ Systemdisk.\ 			
 >>204	string	\rNo\ Systemdisk.\ 			
@@ -1015,75 +1010,45 @@
 # It just looks for a program file name at the root directory
 # It just looks for a program file name at the root directory
 # and loads corresponding file with following execution.
 # and loads corresponding file with following execution.
 # DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes
 # DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes
->>>>499			ubyte&0xDF	>0		\b, COM/EXE Bootloader
->>>>>499		string		x 		\b %-.1s
->>>>>>500		ubyte&0xDF	>0		
->>>>>>>500		string		x 		\b%-.1s
->>>>>>>>501		ubyte&0xDF	>0		
->>>>>>>>>501		string		x 		\b%-.1s
->>>>>>>>>>502		ubyte&0xDF	>0		
->>>>>>>>>>>502		string		x 		\b%-.1s
->>>>>>>>>>>>503		ubyte&0xDF	>0		
->>>>>>>>>>>>>503	string		x 		\b%-.1s
->>>>>>>>>>>>>>504	ubyte&0xDF	>0		
->>>>>>>>>>>>>>>504	string		x 		\b%-.1s
->>>>>>>>>>>>>>>>505	ubyte&0xDF	>0		
->>>>>>>>>>>>>>>>>505	string		x 		\b%-.1s
->>>>>>>>>>>>>>>>>>506	ubyte&0xDF	>0		
->>>>>>>>>>>>>>>>>>>506	string		x 		\b%-.1s
-#name extension
->>>>>507		ubyte&0xDF	>0		\b.
->>>>>>507		string		x 		\b%-.1s
->>>>>>>508		ubyte&0xDF	>0		
->>>>>>>>508		string		x 		\b%-.1s
->>>>>>>>>509		ubyte&0xDF	>0		
->>>>>>>>>>509		string		x 		\b%-.1s
+>>>>499			ubyte&0xDF	>0		\b, COM/EXE Bootloader 
+>>>>>499		use		DOS-filename
 #If the boot sector fails to read any other sector,
 #If the boot sector fails to read any other sector,
 #it prints a very short message ("RE") to the screen and hangs the computer.
 #it prints a very short message ("RE") to the screen and hangs the computer.
 #If the boot sector fails to find needed program in the root directory,
 #If the boot sector fails to find needed program in the root directory,
 #it also hangs with another message ("NF").
 #it also hangs with another message ("NF").
 >>>>>492		string		RENF		\b, FAT (12 bit)
 >>>>>492		string		RENF		\b, FAT (12 bit)
 >>>>>495		string		RENF		\b, FAT (16 bit)
 >>>>>495		string		RENF		\b, FAT (16 bit)
-# http://alexfru.chat.ru/epm.html#bootprog
->494	ubyte	>0x4D					
->>495	string	>E					
->>>495	string	<S					
-#OEM-ID is not reliable
->>>>3	string	BootProg				
-# It just looks for a program file name at the root directory
-# and loads corresponding file with following execution.
-# DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes
->>>>499			ubyte&0xDF	>0		\b, COM/EXE Bootloader
->>>>>499		string		x 		\b %-.1s
->>>>>>500		ubyte&0xDF	>0		
->>>>>>>500		string		x 		\b%-.1s
->>>>>>>>501		ubyte&0xDF	>0		
->>>>>>>>>501		string		x 		\b%-.1s
->>>>>>>>>>502		ubyte&0xDF	>0		
->>>>>>>>>>>502		string		x 		\b%-.1s
->>>>>>>>>>>>503		ubyte&0xDF	>0		
->>>>>>>>>>>>>503	string		x 		\b%-.1s
->>>>>>>>>>>>>>504	ubyte&0xDF	>0		
->>>>>>>>>>>>>>>504	string		x 		\b%-.1s
->>>>>>>>>>>>>>>>505	ubyte&0xDF	>0		
->>>>>>>>>>>>>>>>>505	string		x 		\b%-.1s
->>>>>>>>>>>>>>>>>>506	ubyte&0xDF	>0		
->>>>>>>>>>>>>>>>>>>506	string		x 		\b%-.1s
-#name extension
->>>>>507		ubyte&0xDF	>0		\b.
->>>>>>507		string		x 		\b%-.1s
->>>>>>>508		ubyte&0xDF	>0		
->>>>>>>>508		string		x 		\b%-.1s
->>>>>>>>>509		ubyte&0xDF	>0		
->>>>>>>>>>509		string		x 		\b%-.1s
 #If the boot sector fails to read any other sector,
 #If the boot sector fails to read any other sector,
 #it prints a very short message ("RE") to the screen and hangs the computer.
 #it prints a very short message ("RE") to the screen and hangs the computer.
-#If the boot sector fails to find needed program in the root directory,
-#it also hangs with another message ("NF").
->>>>>492		string		RENF		\b, FAT (12 bit)
->>>>>495		string		RENF		\b, FAT (16 bit)
 # x86 bootloader end
 # x86 bootloader end
 
 
+# added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO
+# and http://en.wikipedia.org/wiki/File_Allocation_Table#FS_Information_Sector
+>0		string		RRaA		
+>>0x1E4		string		rrAa		\b, FSInfosector
+#>>0x1FC	uleshort	=0		SHOULD BE ZERO
+>>>0x1E8	ulelong		<0xffffffff	\b, %u free clusters
+>>>0x1EC	ulelong		<0xffffffff	\b, last allocated cluster %u
+
+# updated by Joerg Jenderek at Sep 2007
+>3	ubyte	0			
+#no active flag
+>>446	ubyte	0			
+# partition 1 not empty
+>>>450	ubyte	>0			
+# partitions 3,4 empty
+>>>>482		ubyte	0			
+>>>>>498	ubyte	0			
+# partition 2 ID=0,5,15
+>>>>>>466	ubyte	<0x10			
+>>>>>>>466	ubyte	0x05			\b, extended partition table
+>>>>>>>466	ubyte	0x0F			\b, extended partition table (LBA)
+>>>>>>>466	ubyte	0x0			\b, extended partition table (last)	
+
+# DOS x86 sector separated and moved from "DOS/MBR boot sector" by Joerg Jenderek at May 2011
+
+>0x200	lelong	0x82564557		\b, BSD disklabel
+
 # by Joerg Jenderek at Apr 2013
 # by Joerg Jenderek at Apr 2013
 #	Print the DOS filenames from directory entry form with 8 right space padded bytes + 3 bytes for extension
 #	Print the DOS filenames from directory entry form with 8 right space padded bytes + 3 bytes for extension
 #	like IO.SYS. MSDOS.SYS , KERNEL.SYS , DRBIO.SYS
 #	like IO.SYS. MSDOS.SYS , KERNEL.SYS , DRBIO.SYS
@@ -1121,33 +1086,6 @@
 >11			ubyte		x		\b+
 >11			ubyte		x		\b+
 >11			use		DOS-filename
 >11			use		DOS-filename
 
 
-# added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO
-# and http://en.wikipedia.org/wiki/File_Allocation_Table#FS_Information_Sector
->0		string		RRaA		
->>0x1E4		string		rrAa		\b, FSInfosector
-#>>0x1FC	uleshort	=0		SHOULD BE ZERO
->>>0x1E8	ulelong		<0xffffffff	\b, %u free clusters
->>>0x1EC	ulelong		<0xffffffff	\b, last allocated cluster %u
-
-# updated by Joerg Jenderek at Sep 2007
->3	ubyte	0			
-#no active flag
->>446	ubyte	0			
-# partition 1 not empty
->>>450	ubyte	>0			
-# partitions 3,4 empty
->>>>482		ubyte	0			
->>>>>498	ubyte	0			
-# partition 2 ID=0,5,15
->>>>>>466	ubyte	<0x10			
->>>>>>>466	ubyte	0x05			\b, extended partition table
->>>>>>>466	ubyte	0x0F			\b, extended partition table (LBA)
->>>>>>>466	ubyte	0x0			\b, extended partition table (last)	
-
-# DOS x86 sector separated and moved from "DOS/MBR boot sector" by Joerg Jenderek at May 2011
-
->0x200	lelong	0x82564557		\b, BSD disklabel
-
 # http://en.wikipedia.org/wiki/Master_boot_record#PTE
 # http://en.wikipedia.org/wiki/Master_boot_record#PTE
 # display standard partition table
 # display standard partition table
 0	name				partition-table
 0	name				partition-table
@@ -1330,7 +1268,7 @@
 #>>>(0x1BC.s+11)		ubyte		x			\b,cfg_def 0x%x
 #>>>(0x1BC.s+11)		ubyte		x			\b,cfg_def 0x%x
 # for older versions
 # for older versions
 >>>(0x1BC.s+9)		ubyte		<2			
 >>>(0x1BC.s+9)		ubyte		<2			
-#>>>>(0x1BC.s+12)	ubyte		18			\b,%u/18 seconds
+#>>>>(0x1BC.s+12)	ubyte		18			\b,%hhu/18 seconds
 >>>>(0x1BC.s+12)	ubyte		!18			\b,%u/18 seconds
 >>>>(0x1BC.s+12)	ubyte		!18			\b,%u/18 seconds
 # floppy A: or B:
 # floppy A: or B:
 >>>>(0x1BC.s+13)	ubyte		<2			\b,floppy 0x%x
 >>>>(0x1BC.s+13)	ubyte		<2			\b,floppy 0x%x
@@ -1373,7 +1311,7 @@
 >>>>0x207	ubyte		x		\b.%u
 >>>>0x207	ubyte		x		\b.%u
 # module_size for 1.94
 # module_size for 1.94
 >>>>0x208	ulelong		<0xffffff	\b, installed partition %u
 >>>>0x208	ulelong		<0xffffff	\b, installed partition %u
-#>>>>0x208	ulelong		=0xffffff	\b, %u (default)
+#>>>>0x208	ulelong		=0xffffff	\b, %lu (default)
 >>>>0x208	ulelong		>0xffffff	\b, installed partition %u
 >>>>0x208	ulelong		>0xffffff	\b, installed partition %u
 # GRUB 0.5.95 unofficial
 # GRUB 0.5.95 unofficial
 >>>>0x20C	ulelong&0x2E300000 0x2E300000	
 >>>>0x20C	ulelong&0x2E300000 0x2E300000	
@@ -1447,14 +1385,14 @@
 >>>>>16		ubyte		=1		\b, FAT  %u
 >>>>>16		ubyte		=1		\b, FAT  %u
 >>>>>16		ubyte		>0
 >>>>>16		ubyte		>0
 >>>>>17		uleshort	>0		\b, root entries %u
 >>>>>17		uleshort	>0		\b, root entries %u
-#>>>>>17	uleshort	=0		\b, root entries %u=0 (usual Fat32)
+#>>>>>17	uleshort	=0		\b, root entries %hu=0 (usual Fat32)
 >>>>>19		uleshort	>0		\b, sectors %u (volumes <=32 MB) 
 >>>>>19		uleshort	>0		\b, sectors %u (volumes <=32 MB) 
-#>>>>>19	uleshort	=0		\b, sectors %u=0 (usual Fat32)
+#>>>>>19	uleshort	=0		\b, sectors %hu=0 (usual Fat32)
 >>>>>21		ubyte		>0xF0		\b, Media descriptor 0x%x
 >>>>>21		ubyte		>0xF0		\b, Media descriptor 0x%x
 #>>>>>21	ubyte		=0xF0		\b, Media descriptor 0x%x (usual floppy)
 #>>>>>21	ubyte		=0xF0		\b, Media descriptor 0x%x (usual floppy)
 >>>>>21		ubyte		<0xF0		\b, Media descriptor 0x%x
 >>>>>21		ubyte		<0xF0		\b, Media descriptor 0x%x
 >>>>>22		uleshort	>0		\b, sectors/FAT %u
 >>>>>22		uleshort	>0		\b, sectors/FAT %u
-#>>>>>22	uleshort	=0		\b, sectors/FAT %u=0 (usual Fat32)
+#>>>>>22	uleshort	=0		\b, sectors/FAT %hu=0 (usual Fat32)
 >>>>>24		uleshort	x		\b, sectors/track %u
 >>>>>24		uleshort	x		\b, sectors/track %u
 >>>>>26		ubyte		>2		\b, heads %u
 >>>>>26		ubyte		>2		\b, heads %u
 #>>>>>26	ubyte		=2		\b, heads %u (usual floppy)
 #>>>>>26	ubyte		=2		\b, heads %u (usual floppy)
@@ -1496,7 +1434,7 @@
 >>>>>>36	ulelong		x		\b, sectors/FAT %u
 >>>>>>36	ulelong		x		\b, sectors/FAT %u
 # http://technet.microsoft.com/en-us/library/cc977221.aspx
 # http://technet.microsoft.com/en-us/library/cc977221.aspx
 >>>>>>40	uleshort	>0		\b, extension flags 0x%x
 >>>>>>40	uleshort	>0		\b, extension flags 0x%x
-#>>>>>>40	uleshort	=0		\b, extension flags %u
+#>>>>>>40	uleshort	=0		\b, extension flags %hu
 >>>>>>42	uleshort	>0		\b, fsVersion %u
 >>>>>>42	uleshort	>0		\b, fsVersion %u
 #>>>>>>42	uleshort	=0		\b, fsVersion %u (usual)
 #>>>>>>42	uleshort	=0		\b, fsVersion %u (usual)
 >>>>>>44	ulelong		>2		\b, rootdir cluster %u
 >>>>>>44	ulelong		>2		\b, rootdir cluster %u
@@ -1555,13 +1493,13 @@
 # Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. 
 # Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. 
 >>>>>>>>>64	lelong		<256		
 >>>>>>>>>64	lelong		<256		
 >>>>>>>>>>64	lelong		<128		\b, clusters/RecordSegment %d
 >>>>>>>>>>64	lelong		<128		\b, clusters/RecordSegment %d
->>>>>>>>>>64	ubyte		>127		\b, bytes/RecordSegment 2^(-1*%hhi)
+>>>>>>>>>>64	ubyte		>127		\b, bytes/RecordSegment 2^(-1*%i)
 # Values 0 to 127 represent index block sizes of 0 to 127 clusters.
 # Values 0 to 127 represent index block sizes of 0 to 127 clusters.
 # Values 128 to 255 represent index block sizes of 2^(256-N) byte
 # Values 128 to 255 represent index block sizes of 2^(256-N) byte
 >>>>>>>>>68	ulelong		<256		
 >>>>>>>>>68	ulelong		<256		
 >>>>>>>>>>68	ulelong		<128		\b, clusters/index block %d
 >>>>>>>>>>68	ulelong		<128		\b, clusters/index block %d
 #>>>>>>>>>>68	ulelong		>127		\b, bytes/index block 2^(256-%d)
 #>>>>>>>>>>68	ulelong		>127		\b, bytes/index block 2^(256-%d)
->>>>>>>>>>68	ubyte		>127		\b, bytes/index block 2^(-1*%hhi)
+>>>>>>>>>>68	ubyte		>127		\b, bytes/index block 2^(-1*%i)
 >>>>>>>>>72	ulequad		x		\b, serial number 0%llx
 >>>>>>>>>72	ulequad		x		\b, serial number 0%llx
 >>>>>>>>>80	ulelong		>0		\b, checksum 0x%x
 >>>>>>>>>80	ulelong		>0		\b, checksum 0x%x
 #>>>>>>>>>80	ulelong		=0		\b, checksum 0x%x=0 (usual)
 #>>>>>>>>>80	ulelong		=0		\b, checksum 0x%x=0 (usual)
@@ -1609,7 +1547,7 @@
 >&-180	lelong		x		average file size %d,
 >&-180	lelong		x		average file size %d,
 >&-176	lelong		x		average number of files in dir %d,
 >&-176	lelong		x		average number of files in dir %d,
 >&-272	lequad		x		pending blocks to free %lld,
 >&-272	lequad		x		pending blocks to free %lld,
->&-264	lelong		x		pending inodes to free %ld,
+>&-264	lelong		x		pending inodes to free %d,
 >&-664	lequad		x		system-wide uuid %0llx,
 >&-664	lequad		x		system-wide uuid %0llx,
 >&-1316	lelong		x		minimum percentage of free blocks %d,
 >&-1316	lelong		x		minimum percentage of free blocks %d,
 >&-1248	lelong		0		TIME optimization
 >&-1248	lelong		0		TIME optimization
@@ -1629,7 +1567,7 @@
 >&-180	lelong		x		average file size %d,
 >&-180	lelong		x		average file size %d,
 >&-176	lelong		x		average number of files in dir %d,
 >&-176	lelong		x		average number of files in dir %d,
 >&-272	lequad		x		pending blocks to free %lld,
 >&-272	lequad		x		pending blocks to free %lld,
->&-264	lelong		x		pending inodes to free %ld,
+>&-264	lelong		x		pending inodes to free %d,
 >&-664	lequad		x		system-wide uuid %0llx,
 >&-664	lequad		x		system-wide uuid %0llx,
 >&-1316	lelong		x		minimum percentage of free blocks %d,
 >&-1316	lelong		x		minimum percentage of free blocks %d,
 >&-1248	lelong		0		TIME optimization
 >&-1248	lelong		0		TIME optimization
@@ -1669,7 +1607,7 @@
 >&-180	belong		x		average file size %d,
 >&-180	belong		x		average file size %d,
 >&-176	belong		x		average number of files in dir %d,
 >&-176	belong		x		average number of files in dir %d,
 >&-272	bequad		x		pending blocks to free %lld,
 >&-272	bequad		x		pending blocks to free %lld,
->&-264	belong		x		pending inodes to free %ld,
+>&-264	belong		x		pending inodes to free %d,
 >&-664	bequad		x		system-wide uuid %0llx,
 >&-664	bequad		x		system-wide uuid %0llx,
 >&-1316	belong		x		minimum percentage of free blocks %d,
 >&-1316	belong		x		minimum percentage of free blocks %d,
 >&-1248	belong		0		TIME optimization
 >&-1248	belong		0		TIME optimization
@@ -1689,7 +1627,7 @@
 >&-180	belong		x		average file size %d,
 >&-180	belong		x		average file size %d,
 >&-176	belong		x		average number of files in dir %d,
 >&-176	belong		x		average number of files in dir %d,
 >&-272	bequad		x		pending blocks to free %lld,
 >&-272	bequad		x		pending blocks to free %lld,
->&-264	belong		x		pending inodes to free %ld,
+>&-264	belong		x		pending inodes to free %d,
 >&-664	bequad		x		system-wide uuid %0llx,
 >&-664	bequad		x		system-wide uuid %0llx,
 >&-1316	belong		x		minimum percentage of free blocks %d,
 >&-1316	belong		x		minimum percentage of free blocks %d,
 >&-1248	belong		0		TIME optimization
 >&-1248	belong		0		TIME optimization
@@ -1965,24 +1903,24 @@
 
 
 # cramfs filesystem - russell@coker.com.au
 # cramfs filesystem - russell@coker.com.au
 0       lelong    0x28cd3d45      Linux Compressed ROM File System data, little endian
 0       lelong    0x28cd3d45      Linux Compressed ROM File System data, little endian
->4      lelong  x size %lu
+>4      lelong  x size %u
 >8      lelong  &1 version #2
 >8      lelong  &1 version #2
 >8      lelong  &2 sorted_dirs
 >8      lelong  &2 sorted_dirs
 >8      lelong  &4 hole_support
 >8      lelong  &4 hole_support
 >32     lelong  x CRC 0x%x,
 >32     lelong  x CRC 0x%x,
->36     lelong  x edition %lu,
->40     lelong  x %lu blocks,
->44     lelong  x %lu files
+>36     lelong  x edition %u,
+>40     lelong  x %u blocks,
+>44     lelong  x %u files
 
 
 0       belong    0x28cd3d45      Linux Compressed ROM File System data, big endian
 0       belong    0x28cd3d45      Linux Compressed ROM File System data, big endian
->4      belong  x size %lu
+>4      belong  x size %u
 >8      belong  &1 version #2
 >8      belong  &1 version #2
 >8      belong  &2 sorted_dirs
 >8      belong  &2 sorted_dirs
 >8      belong  &4 hole_support
 >8      belong  &4 hole_support
 >32     belong  x CRC 0x%x,
 >32     belong  x CRC 0x%x,
->36     belong  x edition %lu,
->40     belong  x %lu blocks,
->44     belong  x %lu files
+>36     belong  x edition %u,
+>40     belong  x %u blocks,
+>44     belong  x %u files
 
 
 # reiserfs - russell@coker.com.au
 # reiserfs - russell@coker.com.au
 0x10034		string	ReIsErFs	ReiserFS V3.5
 0x10034		string	ReIsErFs	ReiserFS V3.5
@@ -2247,8 +2185,8 @@
 >16	ulequad	>0	\b fblock table at %lld,
 >16	ulequad	>0	\b fblock table at %lld,
 >24	ulequad	>0	\b inode table at %lld,
 >24	ulequad	>0	\b inode table at %lld,
 >32	ulequad	>0	\b root at %lld,
 >32	ulequad	>0	\b root at %lld,
->40	ulelong	>0	\b fblock size = %ld,
->44	ulelong	>0	\b block size = %ld,
+>40	ulelong	>0	\b fblock size = %d,
+>44	ulelong	>0	\b block size = %d,
 >48	ulequad	>0	\b bytes = %lld
 >48	ulequad	>0	\b bytes = %lld
 
 
 # Type:	xfs metadump image
 # Type:	xfs metadump image

+ 18 - 8
magic/Magdir/flash

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: flash,v 1.10 2014/03/06 16:07:24 christos Exp $
+# $File: flash,v 1.11 2014/05/02 00:26:49 christos Exp $
 # flash:	file(1) magic for Macromedia Flash file format
 # flash:	file(1) magic for Macromedia Flash file format
 #
 #
 # See
 # See
@@ -9,17 +9,27 @@
 #	http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/\
 #	http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/\
 #	en/devnet/swf/pdf/swf-file-format-spec.pdf page 27
 #	en/devnet/swf/pdf/swf-file-format-spec.pdf page 27
 #
 #
-0	string		FWS		Macromedia Flash data,
->3	byte		x		version %d
+
+0   name        swf-details
+>0	string		F		Macromedia Flash data
 !:mime	application/x-shockwave-flash
 !:mime	application/x-shockwave-flash
-0	string		CWS		Macromedia Flash data (compressed),
+>0	string		C		Macromedia Flash data (compressed)
 !:mime	application/x-shockwave-flash
 !:mime	application/x-shockwave-flash
->3	byte		x		version %d
-0	string		ZWS		Macromedia Flash data (lzma compressed),
+>0	string		Z		Macromedia Flash data (lzma compressed)
 !:mime	application/x-shockwave-flash
 !:mime	application/x-shockwave-flash
->3	byte		x		version %d
+>3   byte        x      \b, version %d
+
+1   string      WS
+>4  lelong      !0
+>>3 byte        255 Suspicious
+>>>0    use     swf-details
+
+>>3 ubyte       <32
+>>>3 ubyte      !0
+>>>>0   use     swf-details
+
 # From: Cal Peake <cp@absolutedigital.net>
 # From: Cal Peake <cp@absolutedigital.net>
-0	string		FLV		Macromedia Flash Video
+0	string		FLV\x01		Macromedia Flash Video
 !:mime	video/x-flv
 !:mime	video/x-flv
 
 
 #
 #

+ 3 - 3
magic/Magdir/fonts

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: fonts,v 1.26 2013/03/09 22:36:00 christos Exp $
+# $File: fonts,v 1.27 2014/04/30 21:41:02 christos Exp $
 # fonts:  file(1) magic for font data
 # fonts:  file(1) magic for font data
 #
 #
 0	search/1	FONT		ASCII vfont text
 0	search/1	FONT		ASCII vfont text
@@ -96,5 +96,5 @@
 0	string		wOFF	Web Open Font Format
 0	string		wOFF	Web Open Font Format
 >4	belong		x	\b, flavor %d
 >4	belong		x	\b, flavor %d
 >8	belong		x	\b, length %d
 >8	belong		x	\b, length %d
->20	beshort		x	\b, version %hd
->22	beshort		x	\b.%hd
+>20	beshort		x	\b, version %d
+>22	beshort		x	\b.%d

+ 2 - 2
magic/Magdir/fortran

@@ -1,7 +1,7 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: fortran,v 1.7 2012/06/21 01:55:02 christos Exp $
+# $File: fortran,v 1.8 2014/06/03 19:01:34 christos Exp $
 # FORTRAN source
 # FORTRAN source
-0	regex/100	\^[Cc][\ \t]	FORTRAN program
+0	regex/100l	\^[Cc][\ \t]	FORTRAN program
 !:mime	text/x-fortran
 !:mime	text/x-fortran
 !:strength - 5
 !:strength - 5

+ 10 - 10
magic/Magdir/games

@@ -1,19 +1,19 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: games,v 1.13 2012/02/13 22:50:50 christos Exp $
+# $File: games,v 1.14 2014/04/30 21:41:02 christos Exp $
 # games:  file(1) for games
 # games:  file(1) for games
 
 
 # Fabio Bonelli <fabiobonelli@libero.it>
 # Fabio Bonelli <fabiobonelli@libero.it>
 # Quake II - III data files
 # Quake II - III data files
 0       string  IDP2        	Quake II 3D Model file,
 0       string  IDP2        	Quake II 3D Model file,
->20     long    x               %lu skin(s),
->8      long    x               (%lu x
->12     long    x 		%lu),
->40     long    x               %lu frame(s),
->16     long    x               Frame size %lu bytes,
->24     long  	x               %lu vertices/frame,
->28     long    x            	%lu texture coordinates,
->32     long    x               %lu triangles/frame
+>20     long    x               %u skin(s),
+>8      long    x               (%u x
+>12     long    x 		%u),
+>40     long    x               %u frame(s),
+>16     long    x               Frame size %u bytes,
+>24     long  	x               %u vertices/frame,
+>28     long    x            	%u texture coordinates,
+>32     long    x               %u triangles/frame
 
 
 0       string  IBSP            Quake
 0       string  IBSP            Quake
 >4      long    0x26            II Map file (BSP)
 >4      long    0x26            II Map file (BSP)
@@ -146,7 +146,7 @@
 
 
 
 
 0	string	MComprHD	MAME CHD compressed hard disk image,
 0	string	MComprHD	MAME CHD compressed hard disk image,
->12	belong	x		version %lu
+>12	belong	x		version %u
 
 
 # doom - submitted by Jon Dowland
 # doom - submitted by Jon Dowland
 
 

+ 3 - 3
magic/Magdir/gimp

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: gimp,v 1.8 2013/12/21 14:29:45 christos Exp $
+# $File: gimp,v 1.9 2014/04/30 21:41:02 christos Exp $
 # GIMP Gradient: file(1) magic for the GIMP's gradient data files (.ggr)
 # GIMP Gradient: file(1) magic for the GIMP's gradient data files (.ggr)
 # by Federico Mena <federico@nuclecu.unam.mx>
 # by Federico Mena <federico@nuclecu.unam.mx>
 
 
@@ -20,8 +20,8 @@
 >9	string		file		version 0,
 >9	string		file		version 0,
 >9	string		v		version
 >9	string		v		version
 >>10	string		>\0		%s,
 >>10	string		>\0		%s,
->14	belong		x		%lu x
->18	belong		x		%lu,
+>14	belong		x		%u x
+>18	belong		x		%u,
 >22     belong          0               RGB Color
 >22     belong          0               RGB Color
 >22     belong          1               Greyscale
 >22     belong          1               Greyscale
 >22     belong          2               Indexed Color
 >22     belong          2               Indexed Color

+ 3 - 3
magic/Magdir/gnome

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: gnome,v 1.3 2013/02/05 15:20:47 christos Exp $
+# $File: gnome,v 1.5 2014/04/30 21:41:02 christos Exp $
 # GNOME related files
 # GNOME related files
 
 
 # Contributed by Josh Triplett
 # Contributed by Josh Triplett
@@ -9,9 +9,9 @@
 >&0       ubyte    0                    \b, major version 0
 >&0       ubyte    0                    \b, major version 0
 >>&0      ubyte    0                    \b, minor version 0
 >>&0      ubyte    0                    \b, minor version 0
 >>>&0     ubyte    0                    \b, crypto type 0 (AES)
 >>>&0     ubyte    0                    \b, crypto type 0 (AES)
->>>&0     ubyte    >0                   \b, crypto type %hhu (unknown)
+>>>&0     ubyte    >0                   \b, crypto type %u (unknown)
 >>>&1     ubyte    0                    \b, hash type 0 (MD5)
 >>>&1     ubyte    0                    \b, hash type 0 (MD5)
->>>&1     ubyte    >0                   \b, hash type %hhu (unknown)
+>>>&1     ubyte    >0                   \b, hash type %u (unknown)
 >>>&2     ubelong  0xFFFFFFFF           \b, name NULL
 >>>&2     ubelong  0xFFFFFFFF           \b, name NULL
 >>>&2     ubelong  !0xFFFFFFFF
 >>>&2     ubelong  !0xFFFFFFFF
 >>>>&-4   ubelong  >255                 \b, name too long for file's pstring type
 >>>>&-4   ubelong  >255                 \b, name too long for file's pstring type

+ 1 - 2
magic/Magdir/gpt

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: gpt,v 1.1 2013/02/18 18:31:09 christos Exp $
+# $File: gpt,v 1.3 2014/04/30 21:41:02 christos Exp $
 #
 #
 # GPT Partition table patterns.
 # GPT Partition table patterns.
 # Author: Rogier Goossens (goossens.rogier@gmail.com)
 # Author: Rogier Goossens (goossens.rogier@gmail.com)
@@ -220,7 +220,6 @@
 0		name		gpt-table
 0		name		gpt-table
 >10		uleshort	x		\b, version %u
 >10		uleshort	x		\b, version %u
 >8		uleshort	x		\b.%u
 >8		uleshort	x		\b.%u
-# a GUID is just like a UUID, except it's displayed mixed-endian.
 >56		ulelong		x		\b, GUID: %08x
 >56		ulelong		x		\b, GUID: %08x
 >60		uleshort	x		\b-%04x
 >60		uleshort	x		\b-%04x
 >62		uleshort	x		\b-%04x
 >62		uleshort	x		\b-%04x

+ 3 - 3
magic/Magdir/graphviz

@@ -1,12 +1,12 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: graphviz,v 1.7 2009/09/19 16:28:09 christos Exp $
+# $File: graphviz,v 1.8 2014/06/03 19:01:34 christos Exp $
 # graphviz:  file(1) magic for http://www.graphviz.org/
 # graphviz:  file(1) magic for http://www.graphviz.org/
 
 
 # FIXME: These patterns match too generally. For example, the first
 # FIXME: These patterns match too generally. For example, the first
 # line matches a LaTeX file containing the word "graph" (with a {
 # line matches a LaTeX file containing the word "graph" (with a {
 # following later) and the second line matches this file.
 # following later) and the second line matches this file.
-#0	regex/100	[\r\n\t\ ]*graph[\r\n\t\ ]+.*\\{	graphviz graph text
+#0	regex/100l	[\r\n\t\ ]*graph[\r\n\t\ ]+.*\\{	graphviz graph text
 #!:mime	text/vnd.graphviz
 #!:mime	text/vnd.graphviz
-#0	regex/100	[\r\n\t\ ]*digraph[\r\n\t\ ]+.*\\{	graphviz digraph text
+#0	regex/100l	[\r\n\t\ ]*digraph[\r\n\t\ ]+.*\\{	graphviz digraph text
 #!:mime	text/vnd.graphviz
 #!:mime	text/vnd.graphviz

+ 15 - 15
magic/Magdir/hp

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: hp,v 1.23 2009/09/19 16:28:09 christos Exp $
+# $File: hp,v 1.24 2014/04/30 21:41:02 christos Exp $
 # hp:  file(1) magic for Hewlett Packard machines (see also "printer")
 # hp:  file(1) magic for Hewlett Packard machines (see also "printer")
 #
 #
 # XXX - somebody should figure out whether any byte order needs to be
 # XXX - somebody should figure out whether any byte order needs to be
@@ -41,10 +41,10 @@
 #### Old Apollo stuff
 #### Old Apollo stuff
 0	beshort		0627		Apollo m68k COFF executable
 0	beshort		0627		Apollo m68k COFF executable
 >18	beshort		^040000		not stripped
 >18	beshort		^040000		not stripped
->22	beshort		>0		- version %ld
+>22	beshort		>0		- version %d
 0	beshort		0624		apollo a88k COFF executable
 0	beshort		0624		apollo a88k COFF executable
 >18	beshort		^040000		not stripped
 >18	beshort		^040000		not stripped
->22	beshort		>0		- version %ld
+>22	beshort		>0		- version %d
 0       long            01203604016     TML 0123 byte-order format
 0       long            01203604016     TML 0123 byte-order format
 0       long            01702407010     TML 1032 byte-order format
 0       long            01702407010     TML 1032 byte-order format
 0       long            01003405017     TML 2301 byte-order format
 0       long            01003405017     TML 2301 byte-order format
@@ -128,58 +128,58 @@
 
 
 #### 500
 #### 500
 0	long		0x02080106	HP s500 relocatable executable
 0	long		0x02080106	HP s500 relocatable executable
->16	long		>0		- version %ld
+>16	long		>0		- version %d
 
 
 0	long		0x02080107	HP s500 executable
 0	long		0x02080107	HP s500 executable
->16	long		>0		- version %ld
+>16	long		>0		- version %d
 
 
 0	long		0x02080108	HP s500 pure executable
 0	long		0x02080108	HP s500 pure executable
->16	long		>0		- version %ld
+>16	long		>0		- version %d
 
 
 #### 200
 #### 200
 0	belong 		0x020c0108	HP s200 pure executable
 0	belong 		0x020c0108	HP s200 pure executable
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x40000000	dynamically linked
 >8	belong		&0x40000000	dynamically linked
 >8	belong		&0x20000000	debuggable
 >8	belong		&0x20000000	debuggable
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
 0	belong		0x020c0107	HP s200 executable
 0	belong		0x020c0107	HP s200 executable
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x40000000	dynamically linked
 >8	belong		&0x40000000	dynamically linked
 >8	belong		&0x20000000	debuggable
 >8	belong		&0x20000000	debuggable
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
 0	belong		0x020c010b	HP s200 demand-load executable
 0	belong		0x020c010b	HP s200 demand-load executable
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x40000000	dynamically linked
 >8	belong		&0x40000000	dynamically linked
 >8	belong		&0x20000000	debuggable
 >8	belong		&0x20000000	debuggable
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
 0	belong		0x020c0106	HP s200 relocatable executable
 0	belong		0x020c0106	HP s200 relocatable executable
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >6	beshort		>0		- highwater %d
 >6	beshort		>0		- highwater %d
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x80000000	save fp regs
 >8	belong		&0x20000000	debuggable
 >8	belong		&0x20000000	debuggable
 >8	belong		&0x10000000	PIC
 >8	belong		&0x10000000	PIC
 
 
 0	belong 		0x020a0108	HP s200 (2.x release) pure executable
 0	belong 		0x020a0108	HP s200 (2.x release) pure executable
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
 0	belong		0x020a0107	HP s200 (2.x release) executable
 0	belong		0x020a0107	HP s200 (2.x release) executable
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
 0	belong		0x020c010e	HP s200 shared library
 0	belong		0x020c010e	HP s200 shared library
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >6	beshort		>0		- highwater %d
 >6	beshort		>0		- highwater %d
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
 0	belong		0x020c010d	HP s200 dynamic load library
 0	belong		0x020c010d	HP s200 dynamic load library
->4	beshort		>0		- version %ld
+>4	beshort		>0		- version %d
 >6	beshort		>0		- highwater %d
 >6	beshort		>0		- highwater %d
 >36	belong		>0		not stripped
 >36	belong		>0		not stripped
 
 
@@ -192,7 +192,7 @@
 0	long		0x015821a6	HP core file
 0	long		0x015821a6	HP core file
 
 
 0	long		0x4da7eee8	HP-WINDOWS font
 0	long		0x4da7eee8	HP-WINDOWS font
->8	byte		>0		- version %ld
+>8	byte		>0		- version %d
 0	string		Bitmapfile	HP Bitmapfile
 0	string		Bitmapfile	HP Bitmapfile
 
 
 0	string		IMGfile	CIS 	compimg HP Bitmapfile
 0	string		IMGfile	CIS 	compimg HP Bitmapfile

+ 5 - 5
magic/Magdir/ibm370

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: ibm370,v 1.8 2009/09/19 16:28:09 christos Exp $
+# $File: ibm370,v 1.9 2014/04/30 21:41:02 christos Exp $
 # ibm370:  file(1) magic for IBM 370 and compatibles.
 # ibm370:  file(1) magic for IBM 370 and compatibles.
 #
 #
 # "ibm370" said that 0x15d == 0535 was "ibm 370 pure executable".
 # "ibm370" said that 0x15d == 0535 was "ibm 370 pure executable".
@@ -36,13 +36,13 @@
 >12	belong		>0		not stripped
 >12	belong		>0		not stripped
 0       beshort		0531		SVR2 executable (Amdahl-UTS)
 0       beshort		0531		SVR2 executable (Amdahl-UTS)
 >12	belong		>0		not stripped
 >12	belong		>0		not stripped
->24     belong		>0		- version %ld
+>24     belong		>0		- version %d
 0	beshort		0534		SVR2 pure executable (Amdahl-UTS)
 0	beshort		0534		SVR2 pure executable (Amdahl-UTS)
 >12	belong		>0		not stripped
 >12	belong		>0		not stripped
->24	belong		>0		- version %ld
+>24	belong		>0		- version %d
 0	beshort		0530		SVR2 pure executable (USS/370)
 0	beshort		0530		SVR2 pure executable (USS/370)
 >12	belong		>0		not stripped
 >12	belong		>0		not stripped
->24	belong		>0		- version %ld
+>24	belong		>0		- version %d
 0	beshort		0535		SVR2 executable (USS/370)
 0	beshort		0535		SVR2 executable (USS/370)
 >12	belong		>0		not stripped
 >12	belong		>0		not stripped
->24	belong		>0		- version %ld
+>24	belong		>0		- version %d

+ 22 - 19
magic/Magdir/images

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: images,v 1.87 2013/12/11 14:14:20 christos Exp $
+# $File: images,v 1.91 2014/04/30 21:41:02 christos Exp $
 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
 # XPM bitmaps)
 # XPM bitmaps)
 #
 #
@@ -18,17 +18,20 @@
 # `xv' recognizes only a subset of the following (RGB with pixelsize = 24)
 # `xv' recognizes only a subset of the following (RGB with pixelsize = 24)
 # `tgatoppm' recognizes a superset (Index may be anything)
 # `tgatoppm' recognizes a superset (Index may be anything)
 1	belong&0xfff7ffff	0x01010000	Targa image data - Map
 1	belong&0xfff7ffff	0x01010000	Targa image data - Map
+!:strength + 2
 >2	byte&8			8		- RLE
 >2	byte&8			8		- RLE
->12	leshort			>0		%hd x
->14	leshort			>0		%hd
+>12	leshort			>0		%d x
+>14	leshort			>0		%d
 1	belong&0xfff7ffff	0x00020000	Targa image data - RGB
 1	belong&0xfff7ffff	0x00020000	Targa image data - RGB
+!:strength + 2
 >2	byte&8			8		- RLE
 >2	byte&8			8		- RLE
->12	leshort			>0		%hd x
->14	leshort			>0		%hd
+>12	leshort			>0		%d x
+>14	leshort			>0		%d
 1	belong&0xfff7ffff	0x00030000	Targa image data - Mono
 1	belong&0xfff7ffff	0x00030000	Targa image data - Mono
+!:strength + 2
 >2	byte&8			8		- RLE
 >2	byte&8			8		- RLE
->12	leshort			>0		%hd x
->14	leshort			>0		%hd
+>12	leshort			>0		%d x
+>14	leshort			>0		%d
 
 
 # PBMPLUS images
 # PBMPLUS images
 # The next byte following the magic is always whitespace.
 # The next byte following the magic is always whitespace.
@@ -128,8 +131,8 @@
 #
 #
 0	string		\x89PNG\x0d\x0a\x1a\x0a		PNG image data
 0	string		\x89PNG\x0d\x0a\x1a\x0a		PNG image data
 !:mime	image/png
 !:mime	image/png
->16	belong		x		\b, %ld x
->20	belong		x		%ld,
+>16	belong		x		\b, %d x
+>20	belong		x		%d,
 >24	byte		x		%d-bit
 >24	byte		x		%d-bit
 >25	byte		0		grayscale,
 >25	byte		0		grayscale,
 >25	byte		2		\b/color RGB,
 >25	byte		2		\b/color RGB,
@@ -164,8 +167,8 @@
 !:apple	8BIMGIFf
 !:apple	8BIMGIFf
 >4	string		7a		\b, version 8%s,
 >4	string		7a		\b, version 8%s,
 >4	string		9a		\b, version 8%s,
 >4	string		9a		\b, version 8%s,
->6	leshort		>0		%hd x
->8	leshort		>0		%hd
+>6	leshort		>0		%d x
+>8	leshort		>0		%d
 #>10	byte		&0x80		color mapped,
 #>10	byte		&0x80		color mapped,
 #>10	byte&0x07	=0x00		2 colors
 #>10	byte&0x07	=0x00		2 colors
 #>10	byte&0x07	=0x01		4 colors
 #>10	byte&0x07	=0x01		4 colors
@@ -483,7 +486,7 @@
 >>>>1	ubyte		3	ver. 2.8 image data, without palette
 >>>>1	ubyte		3	ver. 2.8 image data, without palette
 >>>>1	ubyte		4	for Windows image data
 >>>>1	ubyte		4	for Windows image data
 >>>>1	ubyte		5	ver. 3.0 image data
 >>>>1	ubyte		5	ver. 3.0 image data
->>>>4	uleshort	x	bounding box [%hd,
+>>>>4	uleshort	x	bounding box [%d,
 >>>>6	uleshort	x	%d] -
 >>>>6	uleshort	x	%d] -
 >>>>8	uleshort	x	[%d,
 >>>>8	uleshort	x	[%d,
 >>>>10	uleshort	x	%d],
 >>>>10	uleshort	x	%d],
@@ -618,7 +621,7 @@
 # Author: Hans-Joachim Baader <hjb@pro-linux.de>
 # Author: Hans-Joachim Baader <hjb@pro-linux.de>
 0		string	PaRtImAgE-VoLuMe	PartImage
 0		string	PaRtImAgE-VoLuMe	PartImage
 >0x0020		string	0.6.1		file version %s
 >0x0020		string	0.6.1		file version %s
->>0x0060	lelong	>-1		volume %ld
+>>0x0060	lelong	>-1		volume %d
 #>>0x0064 8 byte identifier
 #>>0x0064 8 byte identifier
 #>>0x007c reserved
 #>>0x007c reserved
 >>0x0200	string	>\0		type %s
 >>0x0200	string	>\0		type %s
@@ -641,8 +644,8 @@
 # Kodak Cineon format for scanned negatives
 # Kodak Cineon format for scanned negatives
 # http://www.kodak.com/US/en/motion/support/dlad/
 # http://www.kodak.com/US/en/motion/support/dlad/
 0	lelong  0xd75f2a80	Cineon image data
 0	lelong  0xd75f2a80	Cineon image data
->200	belong  >0		\b, %ld x
->204	belong  >0		%ld
+>200	belong  >0		\b, %d x
+>204	belong  >0		%d
 
 
 
 
 # Bio-Rad .PIC is an image format used by microscope control systems
 # Bio-Rad .PIC is an image format used by microscope control systems
@@ -654,10 +657,10 @@
 14	leshort <2
 14	leshort <2
 >62	leshort <2
 >62	leshort <2
 >>54	leshort 12345		Bio-Rad .PIC Image File
 >>54	leshort 12345		Bio-Rad .PIC Image File
->>>0	leshort >0		%hd x
->>>2	leshort >0		%hd,
+>>>0	leshort >0		%d x
+>>>2	leshort >0		%d,
 >>>4	leshort =1		1 image in file
 >>>4	leshort =1		1 image in file
->>>4	leshort >1		%hd images in file
+>>>4	leshort >1		%d images in file
 
 
 # From Jan "Yenya" Kasprzak <kas@fi.muni.cz>
 # From Jan "Yenya" Kasprzak <kas@fi.muni.cz>
 # The description of *.mrw format can be found at
 # The description of *.mrw format can be found at
@@ -823,7 +826,7 @@
 0	string/t	[BitmapInfo2]	Polar Monitor Bitmap text
 0	string/t	[BitmapInfo2]	Polar Monitor Bitmap text
 !:mime	image/x-polar-monitor-bitmap
 !:mime	image/x-polar-monitor-bitmap
 
 
-# From: Rick Richardson <rick.richardson@comcast.net>
+# From: Rick Richardson <rickrich@gmail.com>
 0	string	GARMIN\ BITMAP\ 01	Garmin Bitmap file
 0	string	GARMIN\ BITMAP\ 01	Garmin Bitmap file
 
 
 # Type:	Ulead Photo Explorer5 (.pe5)
 # Type:	Ulead Photo Explorer5 (.pe5)

+ 6 - 6
magic/Magdir/intel

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: intel,v 1.11 2013/02/06 14:18:52 christos Exp $
+# $File: intel,v 1.12 2014/04/30 21:41:02 christos Exp $
 # intel:  file(1) magic for x86 Unix
 # intel:  file(1) magic for x86 Unix
 #
 #
 # Various flavors of x86 UNIX executable/object (other than Xenix, which
 # Various flavors of x86 UNIX executable/object (other than Xenix, which
@@ -16,24 +16,24 @@
 #
 #
 0	leshort		0502		basic-16 executable
 0	leshort		0502		basic-16 executable
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
-#>22	leshort		>0		- version %ld
+#>22	leshort		>0		- version %d
 0	leshort		0503		basic-16 executable (TV)
 0	leshort		0503		basic-16 executable (TV)
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
-#>22	leshort		>0		- version %ld
+#>22	leshort		>0		- version %d
 0	leshort		0510		x86 executable
 0	leshort		0510		x86 executable
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
 0	leshort		0511		x86 executable (TV)
 0	leshort		0511		x86 executable (TV)
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
 0	leshort		=0512		iAPX 286 executable small model (COFF)
 0	leshort		=0512		iAPX 286 executable small model (COFF)
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
-#>22	leshort		>0		- version %ld
+#>22	leshort		>0		- version %d
 0	leshort		=0522		iAPX 286 executable large model (COFF)
 0	leshort		=0522		iAPX 286 executable large model (COFF)
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
-#>22	leshort		>0		- version %ld
+#>22	leshort		>0		- version %d
 # SGI labeled the next entry as "iAPX 386 executable" --Dan Quinlan
 # SGI labeled the next entry as "iAPX 386 executable" --Dan Quinlan
 0	leshort		=0514		80386 COFF executable
 0	leshort		=0514		80386 COFF executable
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
->22	leshort		>0		- version %ld
+>22	leshort		>0		- version %d
 
 
 # rom: file(1) magic for BIOS ROM Extensions found in intel machines
 # rom: file(1) magic for BIOS ROM Extensions found in intel machines
 #      mapped into memory between 0xC0000 and 0xFFFFF
 #      mapped into memory between 0xC0000 and 0xFFFFF

+ 1 - 1
magic/Magdir/isz

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: isz,v 1.1 2010/03/27 16:17:09 christos Exp $
+# $File: isz,v 1.3 2014/04/30 21:41:02 christos Exp $
 # ISO Zipped file format 
 # ISO Zipped file format 
 # http://www.ezbsystems.com/isz/iszspec.txt
 # http://www.ezbsystems.com/isz/iszspec.txt
 0	string	IsZ!	ISO Zipped file
 0	string	IsZ!	ISO Zipped file

+ 2 - 2
magic/Magdir/karma

@@ -1,9 +1,9 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: karma,v 1.6 2009/09/19 16:28:10 christos Exp $
+# $File: karma,v 1.7 2014/04/30 21:41:02 christos Exp $
 # karma:  file(1) magic for Karma data files
 # karma:  file(1) magic for Karma data files
 #
 #
 # From <rgooch@atnf.csiro.au>
 # From <rgooch@atnf.csiro.au>
 
 
 0	string		KarmaRHD Version	Karma Data Structure Version
 0	string		KarmaRHD Version	Karma Data Structure Version
->16	belong		x		%lu
+>16	belong		x		%u

+ 18 - 1
magic/Magdir/linux

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: linux,v 1.54 2014/03/02 00:01:29 christos Exp $
+# $File: linux,v 1.57 2014/05/20 20:10:17 christos Exp $
 # linux:  file(1) magic for Linux files
 # linux:  file(1) magic for Linux files
 #
 #
 # Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
 # Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
@@ -396,3 +396,20 @@
 >>0x1042	ubelong		x	\b-%08x
 >>0x1042	ubelong		x	\b-%08x
 >>0x1046	ubeshort	x	\b%04x
 >>0x1046	ubeshort	x	\b%04x
 
 
+# Linux device tree:
+# File format description can be found in the Linux kernel sources at 
+# Documentation/devicetree/booting-without-of.txt
+# From Christoph Biedl
+0		belong		0xd00dfeed
+# structure and strings must be within blob
+>&(8.L)		byte		x
+>>&(12.L)	byte		x
+>>>20		belong		>1	Device Tree Blob version %d
+>>>>4		belong		x	\b, size=%d
+>>>>20		belong		>1
+>>>>>28		belong		x	\b, boot CPU=%d
+>>>>20		belong		>2
+>>>>>32		belong		x	\b, string block size=%d
+>>>>20		belong		>16
+>>>>>36		belong		x	\b, DT structure block size=%d
+

+ 53 - 53
magic/Magdir/mach

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------
 #------------------------------------------------------------
-# $File: mach,v 1.17 2013/03/07 02:22:52 christos Exp $
+# $File: mach,v 1.19 2014/04/30 21:41:02 christos Exp $
 # Mach has two magic numbers, 0xcafebabe and 0xfeedface.
 # Mach has two magic numbers, 0xcafebabe and 0xfeedface.
 # Unfortunately the first, cafebabe, is shared with
 # Unfortunately the first, cafebabe, is shared with
 # Java ByteCode, so they are both handled in the file "cafebabe".
 # Java ByteCode, so they are both handled in the file "cafebabe".
@@ -31,7 +31,7 @@
 >>>4		belong&0x00ffffff	10	vax8650
 >>>4		belong&0x00ffffff	10	vax8650
 >>>4		belong&0x00ffffff	11	vax8800
 >>>4		belong&0x00ffffff	11	vax8800
 >>>4		belong&0x00ffffff	12	uvaxIII
 >>>4		belong&0x00ffffff	12	uvaxIII
->>>4		belong&0x00ffffff	>12	vax subarchitecture=%ld
+>>>4		belong&0x00ffffff	>12	vax subarchitecture=%d
 >>0	belong&0x00ffffff	2	romp
 >>0	belong&0x00ffffff	2	romp
 >>0	belong&0x00ffffff	3	architecture=3
 >>0	belong&0x00ffffff	3	architecture=3
 >>0	belong&0x00ffffff	4	ns32032
 >>0	belong&0x00ffffff	4	ns32032
@@ -51,40 +51,40 @@
 >>>>4	belong&0x00fffff0	0x30		pentium_2_m3
 >>>>4	belong&0x00fffff0	0x30		pentium_2_m3
 >>>>4	belong&0x00fffff0	0x40		pentium_2_m0x40
 >>>>4	belong&0x00fffff0	0x40		pentium_2_m0x40
 >>>>4	belong&0x00fffff0	0x50		pentium_2_m5
 >>>>4	belong&0x00fffff0	0x50		pentium_2_m5
->>>>4	belong&0x00fffff0	>0x50		pentium_2_m0x%lx
+>>>>4	belong&0x00fffff0	>0x50		pentium_2_m0x%x
 >>>4	belong&0x0000000f	7		celeron
 >>>4	belong&0x0000000f	7		celeron
->>>>4	belong&0x00fffff0	0x00		\b_m0x%lx
->>>>4	belong&0x00fffff0	0x10		\b_m0x%lx
->>>>4	belong&0x00fffff0	0x20		\b_m0x%lx
->>>>4	belong&0x00fffff0	0x30		\b_m0x%lx
->>>>4	belong&0x00fffff0	0x40		\b_m0x%lx
->>>>4	belong&0x00fffff0	0x50		\b_m0x%lx
+>>>>4	belong&0x00fffff0	0x00		\b_m0x%x
+>>>>4	belong&0x00fffff0	0x10		\b_m0x%x
+>>>>4	belong&0x00fffff0	0x20		\b_m0x%x
+>>>>4	belong&0x00fffff0	0x30		\b_m0x%x
+>>>>4	belong&0x00fffff0	0x40		\b_m0x%x
+>>>>4	belong&0x00fffff0	0x50		\b_m0x%x
 >>>>4	belong&0x00fffff0	0x60
 >>>>4	belong&0x00fffff0	0x60
 >>>>4	belong&0x00fffff0	0x70		\b_mobile
 >>>>4	belong&0x00fffff0	0x70		\b_mobile
->>>>4	belong&0x00fffff0	>0x70		\b_m0x%lx
+>>>>4	belong&0x00fffff0	>0x70		\b_m0x%x
 >>>4	belong&0x0000000f	8		pentium_3
 >>>4	belong&0x0000000f	8		pentium_3
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x10		\b_m
 >>>>4	belong&0x00fffff0	0x10		\b_m
 >>>>4	belong&0x00fffff0	0x20		\b_xeon
 >>>>4	belong&0x00fffff0	0x20		\b_xeon
->>>>4	belong&0x00fffff0	>0x20		\b_m0x%lx
+>>>>4	belong&0x00fffff0	>0x20		\b_m0x%x
 >>>4	belong&0x0000000f	9		pentiumM
 >>>4	belong&0x0000000f	9		pentiumM
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x00
->>>>4	belong&0x00fffff0	>0x00		\b_m0x%lx
+>>>>4	belong&0x00fffff0	>0x00		\b_m0x%x
 >>>4	belong&0x0000000f	10		pentium_4
 >>>4	belong&0x0000000f	10		pentium_4
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x10		\b_m
 >>>>4	belong&0x00fffff0	0x10		\b_m
->>>>4	belong&0x00fffff0	>0x10		\b_m0x%lx
+>>>>4	belong&0x00fffff0	>0x10		\b_m0x%x
 >>>4	belong&0x0000000f	11		itanium
 >>>4	belong&0x0000000f	11		itanium
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x10		\b_2
 >>>>4	belong&0x00fffff0	0x10		\b_2
->>>>4	belong&0x00fffff0	>0x10		\b_m0x%lx
+>>>>4	belong&0x00fffff0	>0x10		\b_m0x%x
 >>>4	belong&0x0000000f	12		xeon
 >>>4	belong&0x0000000f	12		xeon
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x10		\b_mp
 >>>>4	belong&0x00fffff0	0x10		\b_mp
->>>>4	belong&0x00fffff0	>0x10		\b_m0x%lx
->>>4	belong&0x0000000f	>12		ia32 family=%ld
+>>>>4	belong&0x00fffff0	>0x10		\b_m0x%x
+>>>4	belong&0x0000000f	>12		ia32 family=%d
 >>>>4	belong&0x00fffff0	0x00
 >>>>4	belong&0x00fffff0	0x00
->>>>4	belong&0x00fffff0	>0x00		model=%lx
+>>>>4	belong&0x00fffff0	>0x00		model=%x
 >>0	belong&0x00ffffff	8	mips
 >>0	belong&0x00ffffff	8	mips
 >>>4		belong&0x00ffffff	1	R2300
 >>>4		belong&0x00ffffff	1	R2300
 >>>4		belong&0x00ffffff	2	R2600
 >>>4		belong&0x00ffffff	2	R2600
@@ -93,35 +93,35 @@
 >>>4		belong&0x00ffffff	5	R2000
 >>>4		belong&0x00ffffff	5	R2000
 >>>4		belong&0x00ffffff	6	R3000a
 >>>4		belong&0x00ffffff	6	R3000a
 >>>4		belong&0x00ffffff	7	R3000
 >>>4		belong&0x00ffffff	7	R3000
->>>4		belong&0x00ffffff	>7	subarchitecture=%ld
+>>>4		belong&0x00ffffff	>7	subarchitecture=%d
 >>0	belong&0x00ffffff	9	ns32532
 >>0	belong&0x00ffffff	9	ns32532
 >>0	belong&0x00ffffff	10	mc98000
 >>0	belong&0x00ffffff	10	mc98000
 >>0	belong&0x00ffffff	11	hppa
 >>0	belong&0x00ffffff	11	hppa
 >>>4		belong&0x00ffffff	0	7100
 >>>4		belong&0x00ffffff	0	7100
 >>>4		belong&0x00ffffff	1	7100LC
 >>>4		belong&0x00ffffff	1	7100LC
->>>4		belong&0x00ffffff	>1	subarchitecture=%ld
+>>>4		belong&0x00ffffff	>1	subarchitecture=%d
 >>0	belong&0x00ffffff	12	arm
 >>0	belong&0x00ffffff	12	arm
 >>>4		belong&0x00ffffff	0
 >>>4		belong&0x00ffffff	0
->>>4		belong&0x00ffffff	1	subarchitecture=%ld
->>>4		belong&0x00ffffff	2	subarchitecture=%ld
->>>4		belong&0x00ffffff	3	subarchitecture=%ld
->>>4		belong&0x00ffffff	4	subarchitecture=%ld
+>>>4		belong&0x00ffffff	1	subarchitecture=%d
+>>>4		belong&0x00ffffff	2	subarchitecture=%d
+>>>4		belong&0x00ffffff	3	subarchitecture=%d
+>>>4		belong&0x00ffffff	4	subarchitecture=%d
 >>>4		belong&0x00ffffff	5	\b_v4t
 >>>4		belong&0x00ffffff	5	\b_v4t
 >>>4		belong&0x00ffffff	6	\b_v6
 >>>4		belong&0x00ffffff	6	\b_v6
 >>>4		belong&0x00ffffff	7	\b_v5tej
 >>>4		belong&0x00ffffff	7	\b_v5tej
 >>>4		belong&0x00ffffff	8	\b_xscale
 >>>4		belong&0x00ffffff	8	\b_xscale
 >>>4		belong&0x00ffffff	9	\b_v7
 >>>4		belong&0x00ffffff	9	\b_v7
 >>>4		belong&0x00ffffff	10	\b_v7f
 >>>4		belong&0x00ffffff	10	\b_v7f
->>>4		belong&0x00ffffff	11	subarchitecture=%ld
+>>>4		belong&0x00ffffff	11	subarchitecture=%d
 >>>4		belong&0x00ffffff	12	\b_v7k
 >>>4		belong&0x00ffffff	12	\b_v7k
->>>4		belong&0x00ffffff	>12	subarchitecture=%ld
+>>>4		belong&0x00ffffff	>12	subarchitecture=%d
 #				13	m88k
 #				13	m88k
 >>0	belong&0x00ffffff	13
 >>0	belong&0x00ffffff	13
 >>>4		belong&0x00ffffff	0	mc88000
 >>>4		belong&0x00ffffff	0	mc88000
 >>>4		belong&0x00ffffff	1	mc88100
 >>>4		belong&0x00ffffff	1	mc88100
 >>>4		belong&0x00ffffff	2	mc88110
 >>>4		belong&0x00ffffff	2	mc88110
->>>4		belong&0x00ffffff	>2	mc88000 subarchitecture=%ld
->>0	belong&0x00ffffff	14	sparc
+>>>4		belong&0x00ffffff	>2	mc88000 subarchitecture=%d
+>>0	belong&0x00ffffff	14	SPARC
 >>0	belong&0x00ffffff	15	i860g
 >>0	belong&0x00ffffff	15	i860g
 >>0	belong&0x00ffffff	16	alpha
 >>0	belong&0x00ffffff	16	alpha
 >>0	belong&0x00ffffff	17	rs6000
 >>0	belong&0x00ffffff	17	rs6000
@@ -139,36 +139,36 @@
 >>>4		belong&0x00ffffff	10	\b_7400
 >>>4		belong&0x00ffffff	10	\b_7400
 >>>4		belong&0x00ffffff	11	\b_7450
 >>>4		belong&0x00ffffff	11	\b_7450
 >>>4		belong&0x00ffffff	100	\b_970
 >>>4		belong&0x00ffffff	100	\b_970
->>>4		belong&0x00ffffff	>100	subarchitecture=%ld
->>0	belong&0x00ffffff	>18	architecture=%ld
+>>>4		belong&0x00ffffff	>100	subarchitecture=%d
+>>0	belong&0x00ffffff	>18	architecture=%d
 >0	belong&0x01000000	0x01000000
 >0	belong&0x01000000	0x01000000
 #
 #
 # 64-bit ABIs.
 # 64-bit ABIs.
 #
 #
->>0	belong&0x00ffffff	0	64-bit architecture=%ld
->>0	belong&0x00ffffff	1	64-bit architecture=%ld
->>0	belong&0x00ffffff	2	64-bit architecture=%ld
->>0	belong&0x00ffffff	3	64-bit architecture=%ld
->>0	belong&0x00ffffff	4	64-bit architecture=%ld
->>0	belong&0x00ffffff	5	64-bit architecture=%ld
->>0	belong&0x00ffffff	6	64-bit architecture=%ld
+>>0	belong&0x00ffffff	0	64-bit architecture=%d
+>>0	belong&0x00ffffff	1	64-bit architecture=%d
+>>0	belong&0x00ffffff	2	64-bit architecture=%d
+>>0	belong&0x00ffffff	3	64-bit architecture=%d
+>>0	belong&0x00ffffff	4	64-bit architecture=%d
+>>0	belong&0x00ffffff	5	64-bit architecture=%d
+>>0	belong&0x00ffffff	6	64-bit architecture=%d
 >>0	belong&0x00ffffff	7	x86_64
 >>0	belong&0x00ffffff	7	x86_64
->>>4		belong&0x00ffffff	0	subarchitecture=%ld
->>>4		belong&0x00ffffff	1	subarchitecture=%ld
->>>4		belong&0x00ffffff	2	subarchitecture=%ld
+>>>4		belong&0x00ffffff	0	subarchitecture=%d
+>>>4		belong&0x00ffffff	1	subarchitecture=%d
+>>>4		belong&0x00ffffff	2	subarchitecture=%d
 >>>4		belong&0x00ffffff	3
 >>>4		belong&0x00ffffff	3
 >>>4		belong&0x00ffffff	4	\b_arch1
 >>>4		belong&0x00ffffff	4	\b_arch1
->>>4		belong&0x00ffffff	>4	subarchitecture=%ld
->>0	belong&0x00ffffff	8	64-bit architecture=%ld
->>0	belong&0x00ffffff	9	64-bit architecture=%ld
->>0	belong&0x00ffffff	10	64-bit architecture=%ld
->>0	belong&0x00ffffff	11	64-bit architecture=%ld
->>0	belong&0x00ffffff	12	64-bit architecture=%ld
->>0	belong&0x00ffffff	13	64-bit architecture=%ld
->>0	belong&0x00ffffff	14	64-bit architecture=%ld
->>0	belong&0x00ffffff	15	64-bit architecture=%ld
->>0	belong&0x00ffffff	16	64-bit architecture=%ld
->>0	belong&0x00ffffff	17	64-bit architecture=%ld
+>>>4		belong&0x00ffffff	>4	subarchitecture=%d
+>>0	belong&0x00ffffff	8	64-bit architecture=%d
+>>0	belong&0x00ffffff	9	64-bit architecture=%d
+>>0	belong&0x00ffffff	10	64-bit architecture=%d
+>>0	belong&0x00ffffff	11	64-bit architecture=%d
+>>0	belong&0x00ffffff	12	64-bit architecture=%d
+>>0	belong&0x00ffffff	13	64-bit architecture=%d
+>>0	belong&0x00ffffff	14	64-bit architecture=%d
+>>0	belong&0x00ffffff	15	64-bit architecture=%d
+>>0	belong&0x00ffffff	16	64-bit architecture=%d
+>>0	belong&0x00ffffff	17	64-bit architecture=%d
 >>0	belong&0x00ffffff	18	ppc64
 >>0	belong&0x00ffffff	18	ppc64
 >>>4		belong&0x00ffffff	0
 >>>4		belong&0x00ffffff	0
 >>>4		belong&0x00ffffff	1		\b_601
 >>>4		belong&0x00ffffff	1		\b_601
@@ -183,8 +183,8 @@
 >>>4		belong&0x00ffffff	10		\b_7400
 >>>4		belong&0x00ffffff	10		\b_7400
 >>>4		belong&0x00ffffff	11		\b_7450
 >>>4		belong&0x00ffffff	11		\b_7450
 >>>4		belong&0x00ffffff	100		\b_970
 >>>4		belong&0x00ffffff	100		\b_970
->>>4		belong&0x00ffffff	>100		subarchitecture=%ld
->>0	belong&0x00ffffff	>18	64-bit architecture=%ld
+>>>4		belong&0x00ffffff	>100		subarchitecture=%d
+>>0	belong&0x00ffffff	>18	64-bit architecture=%d
 
 
 
 
 0	name		mach-o-be
 0	name		mach-o-be
@@ -202,7 +202,7 @@
 >12	belong		10		dSYM companion file
 >12	belong		10		dSYM companion file
 >12	belong		11		kext bundle
 >12	belong		11		kext bundle
 >12	belong		>11
 >12	belong		>11
->>12	belong		x		filetype=%ld
+>>12	belong		x		filetype=%d
 
 
 #
 #
 0	lelong&0xfffffffe	0xfeedface	Mach-O
 0	lelong&0xfffffffe	0xfeedface	Mach-O

+ 25 - 0
magic/Magdir/map

@@ -0,0 +1,25 @@
+
+
+#------------------------------------------------------------------------------
+# $File: map,v 1.1 2014/06/03 18:22:25 christos Exp $
+# map:  file(1) magic for Map data
+#
+
+# Garmin .FIT files http://pub.ks-and-ks.ne.jp/cycling/edge500_fit.shtml
+8	string	.FIT		FIT Map data
+>15	byte	0
+>>35	belong	x		\b, unit id %d
+# 20 years after unix epoch
+>>39	lelong	x		\b, serial %u
+>>43	ledate/631152000 x	\b, %s
+
+>>47	leshort x		\b, manufacturer %d
+>>47	leshort	1		\b (garmin)
+>>49	leshort x		\b, product %d
+>>53	byte	x		\b, type %d
+>>53	byte	1		\b (Device)
+>>53	byte	2		\b (Settings)
+>>53	byte	3		\b (Sports/Cycling)
+>>53	byte	4		\b (Activity)
+>>53	byte	8		\b (Elevations)
+>>53	byte	10		\b (Totals)

+ 6 - 6
magic/Magdir/marc21

@@ -12,17 +12,17 @@
 20	string	45	
 20	string	45	
 
 
 # leader starts with 5 digits, followed by codes specific to MARC format
 # leader starts with 5 digits, followed by codes specific to MARC format
->0	regex/1	(^[0-9]{5})[acdnp][^bhlnqsu-z]	MARC21 Bibliographic
+>0	regex/1l	(^[0-9]{5})[acdnp][^bhlnqsu-z]	MARC21 Bibliographic
 !:mime	application/marc
 !:mime	application/marc
->0	regex/1	(^[0-9]{5})[acdnosx][z]	MARC21 Authority
+>0	regex/1l	(^[0-9]{5})[acdnosx][z]	MARC21 Authority
 !:mime	application/marc
 !:mime	application/marc
->0	regex/1	(^[0-9]{5})[cdn][uvxy]	MARC21 Holdings
+>0	regex/1l	(^[0-9]{5})[cdn][uvxy]	MARC21 Holdings
 !:mime	application/marc
 !:mime	application/marc
-0	regex/1	(^[0-9]{5})[acdn][w]	MARC21 Classification
+0	regex/1l	(^[0-9]{5})[acdn][w]	MARC21 Classification
 !:mime	application/marc
 !:mime	application/marc
->0	regex/1	(^[0-9]{5})[cdn][q]	MARC21 Community
+>0	regex/1l	(^[0-9]{5})[cdn][q]	MARC21 Community
 !:mime	application/marc
 !:mime	application/marc
 
 
 # leader position 22-23, should be "00" but is it?
 # leader position 22-23, should be "00" but is it?
->0	regex/1	(^.{21})([^0]{2})	(non-conforming)
+>0	regex/1l	(^.{21})([^0]{2})	(non-conforming)
 !:mime	application/marc
 !:mime	application/marc

+ 23 - 23
magic/Magdir/mips

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: mips,v 1.9 2013/01/12 03:09:51 christos Exp $
+# $File: mips,v 1.10 2014/04/30 21:41:02 christos Exp $
 # mips:  file(1) magic for MIPS ECOFF and Ucode, as used in SGI IRIX
 # mips:  file(1) magic for MIPS ECOFF and Ucode, as used in SGI IRIX
 # and DEC Ultrix
 # and DEC Ultrix
 #
 #
@@ -10,8 +10,8 @@
 >20	beshort	0413		(paged)
 >20	beshort	0413		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->22	byte	x		- version %ld
->23	byte	x		\b.%ld
+>22	byte	x		- version %d
+>23	byte	x		\b.%d
 #
 #
 0	beshort	0x0162		MIPSEL-BE ECOFF executable
 0	beshort	0x0162		MIPSEL-BE ECOFF executable
 >20	beshort	0407		(impure)
 >20	beshort	0407		(impure)
@@ -20,7 +20,7 @@
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
 >23	byte	x		- version %d
 >23	byte	x		- version %d
->22	byte	x		\b.%ld
+>22	byte	x		\b.%d
 #
 #
 0	beshort	0x6001		MIPSEB-LE ECOFF executable
 0	beshort	0x6001		MIPSEB-LE ECOFF executable
 >20	beshort	03401		(impure)
 >20	beshort	03401		(impure)
@@ -29,7 +29,7 @@
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
 >23	byte	x		- version %d
 >23	byte	x		- version %d
->22	byte	x		\b.%ld
+>22	byte	x		\b.%d
 #
 #
 0	beshort	0x6201		MIPSEL ECOFF executable
 0	beshort	0x6201		MIPSEL ECOFF executable
 >20	beshort	03401		(impure)
 >20	beshort	03401		(impure)
@@ -37,8 +37,8 @@
 >20	beshort	05401		(paged)
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->23	byte	x		- version %ld
->22	byte	x		\b.%ld
+>23	byte	x		- version %d
+>22	byte	x		\b.%d
 #
 #
 # MIPS 2 additions
 # MIPS 2 additions
 #
 #
@@ -48,8 +48,8 @@
 >20	beshort	0413		(paged)
 >20	beshort	0413		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->22	byte	x		- version %ld
->23	byte	x		\b.%ld
+>22	byte	x		- version %d
+>23	byte	x		\b.%d
 #
 #
 0	beshort	0x0166		MIPSEL-BE MIPS-II ECOFF executable
 0	beshort	0x0166		MIPSEL-BE MIPS-II ECOFF executable
 >20	beshort	0407		(impure)
 >20	beshort	0407		(impure)
@@ -57,8 +57,8 @@
 >20	beshort	0413		(paged)
 >20	beshort	0413		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->22	byte	x		- version %ld
->23	byte	x		\b.%ld
+>22	byte	x		- version %d
+>23	byte	x		\b.%d
 #
 #
 0	beshort	0x6301		MIPSEB-LE MIPS-II ECOFF executable
 0	beshort	0x6301		MIPSEB-LE MIPS-II ECOFF executable
 >20	beshort	03401		(impure)
 >20	beshort	03401		(impure)
@@ -66,8 +66,8 @@
 >20	beshort	05401		(paged)
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->23	byte	x		- version %ld
->22	byte	x		\b.%ld
+>23	byte	x		- version %d
+>22	byte	x		\b.%d
 #
 #
 0	beshort	0x6601		MIPSEL MIPS-II ECOFF executable
 0	beshort	0x6601		MIPSEL MIPS-II ECOFF executable
 >20	beshort	03401		(impure)
 >20	beshort	03401		(impure)
@@ -75,8 +75,8 @@
 >20	beshort	05401		(paged)
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->23	byte	x		- version %ld
->22	byte	x		\b.%ld
+>23	byte	x		- version %d
+>22	byte	x		\b.%d
 #
 #
 # MIPS 3 additions
 # MIPS 3 additions
 #
 #
@@ -86,8 +86,8 @@
 >20	beshort	0413		(paged)
 >20	beshort	0413		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->22	byte	x		- version %ld
->23	byte	x		\b.%ld
+>22	byte	x		- version %d
+>23	byte	x		\b.%d
 #
 #
 0	beshort	0x0142		MIPSEL-BE MIPS-III ECOFF executable
 0	beshort	0x0142		MIPSEL-BE MIPS-III ECOFF executable
 >20	beshort	0407		(impure)
 >20	beshort	0407		(impure)
@@ -95,8 +95,8 @@
 >20	beshort	0413		(paged)
 >20	beshort	0413		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->22	byte	x		- version %ld
->23	byte	x		\b.%ld
+>22	byte	x		- version %d
+>23	byte	x		\b.%d
 #
 #
 0	beshort	0x4001		MIPSEB-LE MIPS-III ECOFF executable
 0	beshort	0x4001		MIPSEB-LE MIPS-III ECOFF executable
 >20	beshort	03401		(impure)
 >20	beshort	03401		(impure)
@@ -104,8 +104,8 @@
 >20	beshort	05401		(paged)
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->23	byte	x		- version %ld
->22	byte	x		\b.%ld
+>23	byte	x		- version %d
+>22	byte	x		\b.%d
 #
 #
 0	beshort	0x4201		MIPSEL MIPS-III ECOFF executable
 0	beshort	0x4201		MIPSEL MIPS-III ECOFF executable
 >20	beshort	03401		(impure)
 >20	beshort	03401		(impure)
@@ -113,8 +113,8 @@
 >20	beshort	05401		(paged)
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >8	belong	0		stripped
->23	byte	x		- version %ld
->22	byte	x		\b.%ld
+>23	byte	x		- version %d
+>22	byte	x		\b.%d
 #
 #
 0	beshort	0x180		MIPSEB Ucode
 0	beshort	0x180		MIPSEB Ucode
 0	beshort	0x182		MIPSEL-BE Ucode
 0	beshort	0x182		MIPSEL-BE Ucode

+ 15 - 15
magic/Magdir/motorola

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: motorola,v 1.10 2009/09/19 16:28:11 christos Exp $
+# $File: motorola,v 1.11 2014/04/30 21:41:02 christos Exp $
 # motorola:  file(1) magic for Motorola 68K and 88K binaries
 # motorola:  file(1) magic for Motorola 68K and 88K binaries
 #
 #
 # 68K
 # 68K
@@ -40,27 +40,27 @@
 # not larger than 1 MB (which is a lot on ST).
 # not larger than 1 MB (which is a lot on ST).
 # The additional 0x601b distinction I took from Doug Lee's magic.
 # The additional 0x601b distinction I took from Doug Lee's magic.
 0	belong&0xFFFFFFF0	0x601A0000	Atari ST M68K contiguous executable
 0	belong&0xFFFFFFF0	0x601A0000	Atari ST M68K contiguous executable
->2	belong			x		(txt=%ld,
->6	belong			x		dat=%ld,
->10	belong			x		bss=%ld,
->14	belong			x		sym=%ld)
+>2	belong			x		(txt=%d,
+>6	belong			x		dat=%d,
+>10	belong			x		bss=%d,
+>14	belong			x		sym=%d)
 0	belong&0xFFFFFFF0	0x601B0000	Atari ST M68K non-contig executable
 0	belong&0xFFFFFFF0	0x601B0000	Atari ST M68K non-contig executable
->2	belong			x		(txt=%ld,
->6	belong			x		dat=%ld,
->10	belong			x		bss=%ld,
->14	belong			x		sym=%ld)
+>2	belong			x		(txt=%d,
+>6	belong			x		dat=%d,
+>10	belong			x		bss=%d,
+>14	belong			x		sym=%d)
 
 
 # Atari ST/TT... program format (sent by Wolfram Kleff <kleff@cs.uni-bonn.de>)
 # Atari ST/TT... program format (sent by Wolfram Kleff <kleff@cs.uni-bonn.de>)
 0       beshort         0x601A          Atari 68xxx executable,
 0       beshort         0x601A          Atari 68xxx executable,
->2      belong          x               text len %lu,
->6      belong          x               data len %lu,
->10     belong          x               BSS len %lu,
->14     belong          x               symboltab len %lu,
+>2      belong          x               text len %u,
+>6      belong          x               data len %u,
+>10     belong          x               BSS len %u,
+>14     belong          x               symboltab len %u,
 >18     belong          0
 >18     belong          0
 >22     belong          &0x01           fastload flag,
 >22     belong          &0x01           fastload flag,
 >22     belong          &0x02           may be loaded to alternate RAM,
 >22     belong          &0x02           may be loaded to alternate RAM,
 >22     belong          &0x04           malloc may be from alternate RAM,
 >22     belong          &0x04           malloc may be from alternate RAM,
->22     belong          x               flags: 0x%lX,
+>22     belong          x               flags: 0x%X,
 >26     beshort         0               no relocation tab
 >26     beshort         0               no relocation tab
 >26     beshort         !0              + relocation tab
 >26     beshort         !0              + relocation tab
 >30     string          SFX             [Self-Extracting LZH SFX archive]
 >30     string          SFX             [Self-Extracting LZH SFX archive]
@@ -68,4 +68,4 @@
 >44     string          ZIP!            [Self-Extracting ZIP SFX archive]
 >44     string          ZIP!            [Self-Extracting ZIP SFX archive]
 
 
 0       beshort         0x0064          Atari 68xxx CPX file
 0       beshort         0x0064          Atari 68xxx CPX file
->8      beshort         x               (version %04lx)
+>8      beshort         x               (version %04x)

+ 26 - 104
magic/Magdir/msdos

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: msdos,v 1.92 2014/03/14 18:47:29 christos Exp $
+# $File: msdos,v 1.100 2014/06/03 19:17:27 christos Exp $
 # msdos:  file(1) magic for MS-DOS files
 # msdos:  file(1) magic for MS-DOS files
 #
 #
 
 
@@ -56,6 +56,7 @@
 
 
 # Maybe it's a PE?
 # Maybe it's a PE?
 >>(0x3c.l) string PE\0\0 PE
 >>(0x3c.l) string PE\0\0 PE
+!:mime	application/x-dosexec
 >>>(0x3c.l+24)	leshort		0x010b	\b32 executable
 >>>(0x3c.l+24)	leshort		0x010b	\b32 executable
 >>>(0x3c.l+24)	leshort		0x020b	\b32+ executable
 >>>(0x3c.l+24)	leshort		0x020b	\b32+ executable
 >>>(0x3c.l+24)	leshort		0x0107	ROM image
 >>>(0x3c.l+24)	leshort		0x0107	ROM image
@@ -134,8 +135,10 @@
 # Hmm, not a PE but the relocation table is too high for a traditional DOS exe,
 # Hmm, not a PE but the relocation table is too high for a traditional DOS exe,
 # must be one of the unusual subformats.
 # must be one of the unusual subformats.
 >>(0x3c.l) string !PE\0\0 MS-DOS executable
 >>(0x3c.l) string !PE\0\0 MS-DOS executable
+!:mime	application/x-dosexec
 
 
 >>(0x3c.l)		string		NE \b, NE
 >>(0x3c.l)		string		NE \b, NE
+!:mime	application/x-dosexec
 >>>(0x3c.l+0x36)	byte		1 for OS/2 1.x
 >>>(0x3c.l+0x36)	byte		1 for OS/2 1.x
 >>>(0x3c.l+0x36)	byte		2 for MS Windows 3.x
 >>>(0x3c.l+0x36)	byte		2 for MS Windows 3.x
 >>>(0x3c.l+0x36)	byte		3 for MS-DOS
 >>>(0x3c.l+0x36)	byte		3 for MS-DOS
@@ -150,6 +153,7 @@
 >>>(0x3c.l+0x70)	search/0x80	WinZip(R)\ Self-Extractor \b, ZIP self-extracting archive (WinZip)
 >>>(0x3c.l+0x70)	search/0x80	WinZip(R)\ Self-Extractor \b, ZIP self-extracting archive (WinZip)
 
 
 >>(0x3c.l)		string		LX\0\0 \b, LX
 >>(0x3c.l)		string		LX\0\0 \b, LX
+!:mime	application/x-dosexec
 >>>(0x3c.l+0x0a)	leshort		<1 (unknown OS)
 >>>(0x3c.l+0x0a)	leshort		<1 (unknown OS)
 >>>(0x3c.l+0x0a)	leshort		1 for OS/2
 >>>(0x3c.l+0x0a)	leshort		1 for OS/2
 >>>(0x3c.l+0x0a)	leshort		2 for MS Windows
 >>>(0x3c.l+0x0a)	leshort		2 for MS Windows
@@ -168,8 +172,10 @@
 
 
 # MS Windows system file, supposedly a collection of LE executables
 # MS Windows system file, supposedly a collection of LE executables
 >>(0x3c.l)		string		W3 \b, W3 for MS Windows
 >>(0x3c.l)		string		W3 \b, W3 for MS Windows
+!:mime	application/x-dosexec
 
 
 >>(0x3c.l)		string		LE\0\0 \b, LE executable
 >>(0x3c.l)		string		LE\0\0 \b, LE executable
+!:mime	application/x-dosexec
 >>>(0x3c.l+0x0a)	leshort		1
 >>>(0x3c.l+0x0a)	leshort		1
 # some DOS extenders use LE files with OS/2 header
 # some DOS extenders use LE files with OS/2 header
 >>>>0x240		search/0x100	DOS/4G for MS-DOS, DOS4GW DOS extender
 >>>>0x240		search/0x100	DOS/4G for MS-DOS, DOS4GW DOS extender
@@ -196,6 +202,7 @@
 # and definitely not NE/LE/LX/PE
 # and definitely not NE/LE/LX/PE
 >>0x3c		lelong	>0x20000000
 >>0x3c		lelong	>0x20000000
 >>>(4.s*512)	leshort !0x014c \b, MZ for MS-DOS
 >>>(4.s*512)	leshort !0x014c \b, MZ for MS-DOS
+!:mime	application/x-dosexec
 # header data too small for extended executable
 # header data too small for extended executable
 >2		long	!0
 >2		long	!0
 >>0x18		leshort <0x40
 >>0x18		leshort <0x40
@@ -203,6 +210,7 @@
 
 
 >>>>&(2.s-514)	string	!LE
 >>>>&(2.s-514)	string	!LE
 >>>>>&-2	string	!BW \b, MZ for MS-DOS
 >>>>>&-2	string	!BW \b, MZ for MS-DOS
+!:mime	application/x-dosexec
 >>>>&(2.s-514)	string	LE \b, LE
 >>>>&(2.s-514)	string	LE \b, LE
 >>>>>0x240	search/0x100	DOS/4G for MS-DOS, DOS4GW DOS extender
 >>>>>0x240	search/0x100	DOS/4G for MS-DOS, DOS4GW DOS extender
 # educated guess since indirection is still not capable enough for complex offset
 # educated guess since indirection is still not capable enough for complex offset
@@ -214,6 +222,7 @@
 
 
 # This sequence skips to the first COFF segment, usually .text
 # This sequence skips to the first COFF segment, usually .text
 >(4.s*512)	leshort		0x014c \b, COFF
 >(4.s*512)	leshort		0x014c \b, COFF
+!:mime	application/x-dosexec
 >>(8.s*16)	string		go32stub for MS-DOS, DJGPP go32 DOS extender
 >>(8.s*16)	string		go32stub for MS-DOS, DJGPP go32 DOS extender
 >>(8.s*16)	string		emx
 >>(8.s*16)	string		emx
 >>>&1		string		x for DOS, Win or OS/2, emx %s
 >>>&1		string		x for DOS, Win or OS/2, emx %s
@@ -373,7 +382,7 @@
 # they have their real name at offset 22
 # they have their real name at offset 22
 >>>>>22		string			>\0			\b%-.5s
 >>>>>22		string			>\0			\b%-.5s
 >4	uleshort&0x8000			0x0000			
 >4	uleshort&0x8000			0x0000			
-# 32 bit sector adressing ( > 32 MB) for block devices
+# 32 bit sector addressing ( > 32 MB) for block devices
 >>4	uleshort&0x0002			0x0002			\b,32-bit sector-
 >>4	uleshort&0x0002			0x0002			\b,32-bit sector-
 # support by driver functions 13h, 17h, 18h
 # support by driver functions 13h, 17h, 18h
 >4	uleshort&0x0040			0x0040			\b,IOCTL-
 >4	uleshort&0x0040			0x0040			\b,IOCTL-
@@ -590,7 +599,6 @@
 >4  ubyte   !0  \b, %d colors
 >4  ubyte   !0  \b, %d colors
 
 
 0   belong  0x00000100
 0   belong  0x00000100
-
 >9  byte    0
 >9  byte    0
 >>0 byte    x           MS Windows icon resource
 >>0 byte    x           MS Windows icon resource
 !:mime	image/x-icon
 !:mime	image/x-icon
@@ -741,6 +749,19 @@
 0	leshort		0x223e9f78	TNEF
 0	leshort		0x223e9f78	TNEF
 !:mime	application/vnd.ms-tnef
 !:mime	application/vnd.ms-tnef
 
 
+# Norton Guide (.NG , .HLP) files added by Joerg Jenderek from source NG2HTML.C
+# of http://www.davep.org/norton-guides/ng2h-105.tgz
+# http://en.wikipedia.org/wiki/Norton_Guides
+0	string		NG\0\001	
+# only value 0x100 found at offset 2
+>2	ulelong		0x00000100	Norton Guide
+# Title[40]
+>>8	string		>\0		"%-.40s"
+#>>6	uleshort	x		\b, MenuCount=%u
+# szCredits[5][66]
+>>48	string		>\0		\b, %-.66s
+>>114	string		>\0		%-.66s
+
 # 4DOS help (.HLP) files added by Joerg Jenderek from source TPHELP.PAS 
 # 4DOS help (.HLP) files added by Joerg Jenderek from source TPHELP.PAS 
 # of http://www.4dos.info/
 # of http://www.4dos.info/
 # pointer,HelpID[8]=4DHnnnmm
 # pointer,HelpID[8]=4DHnnnmm
@@ -795,105 +816,6 @@
 >40	string	\ EMF		Windows Enhanced Metafile (EMF) image data
 >40	string	\ EMF		Windows Enhanced Metafile (EMF) image data
 >>44	ulelong x		version 0x%x
 >>44	ulelong x		version 0x%x
 
 
-# From: Alex Beregszaszi <alex@fsn.hu>
-0	string/b	COWD		VMWare3
->4	byte	3		disk image
->>32	lelong	x		(%d/
->>36	lelong	x		\b%d/
->>40	lelong	x		\b%d)
->4	byte	2		undoable disk image
->>32	string	>\0		(%s)
-
-0	string/b	VMDK		 VMware4 disk image
-0	string/b	KDMV		 VMware4 disk image
-
-#--------------------------------------------------------------------
-# Qemu Emulator Images
-# Lines written by Friedrich Schwittay (f.schwittay@yousable.de)
-# Updated by Adam Buchbinder (adam.buchbinder@gmail.com)
-# Made by reading sources, reading documentation, and doing trial and error
-# on existing QCOW files
-0	string/b	QFI\xFB	QEMU QCOW Image
-
-# Uncomment the following line to display Magic (only used for debugging
-# this magic number)
-#>0	string/b	x	, Magic: %s
-
-# There are currently 2 Versions: "1" and "2".
-# http://www.gnome.org/~markmc/qcow-image-format-version-1.html
->4	belong	1	(v1)
-
-# Using the existence of the Backing File Offset to determine whether
-# to read Backing File Information
->>12	belong	 >0	 \b, has backing file (
-# Note that this isn't a null-terminated string; the length is actually
-# (16.L). Assuming a null-terminated string happens to work usually, but it
-# may spew junk until it reaches a \0 in some cases.
->>>(12.L)	 string >\0	\bpath %s
-
-# Modification time of the Backing File
-# Really useful if you want to know if your backing
-# file is still usable together with this image
->>>>20	bedate >0	\b, mtime %s)
->>>>20	default x	\b)
-
-# Size is stored in bytes in a big-endian u64.
->>24	bequad	x	 \b, %lld bytes
-
-# 1 for AES encryption, 0 for none.
->>36	belong	1	\b, AES-encrypted
-
-# http://www.gnome.org/~markmc/qcow-image-format.html
->4	belong	2	(v2)
-# Using the existence of the Backing File Offset to determine whether
-# to read Backing File Information
->>8	bequad  >0	 \b, has backing file
-# Note that this isn't a null-terminated string; the length is actually
-# (16.L). Assuming a null-terminated string happens to work usually, but it
-# may spew junk until it reaches a \0 in some cases. Also, since there's no
-# .Q modifier, we just use the bottom four bytes as an offset. Note that if
-# the file is over 4G, and the backing file path is stored after the first 4G,
-# the wrong filename will be printed. (This should be (8.Q), when that syntax
-# is introduced.)
->>>(12.L)	 string >\0	(path %s)
->>24	bequad	x	\b, %lld bytes
->>32	belong	1	\b, AES-encrypted
-
->4	belong	3	(v3)
-# Using the existence of the Backing File Offset to determine whether
-# to read Backing File Information
->>8	bequad  >0	 \b, has backing file
-# Note that this isn't a null-terminated string; the length is actually
-# (16.L). Assuming a null-terminated string happens to work usually, but it
-# may spew junk until it reaches a \0 in some cases. Also, since there's no
-# .Q modifier, we just use the bottom four bytes as an offset. Note that if
-# the file is over 4G, and the backing file path is stored after the first 4G,
-# the wrong filename will be printed. (This should be (8.Q), when that syntax
-# is introduced.)
->>>(12.L)	 string >\0	(path %s)
->>24	bequad	x	\b, %lld bytes
->>32	belong	1	\b, AES-encrypted
-
->4	default x	(unknown version)
-
-0	string/b	QEVM		QEMU suspend to disk image
-
-# QEMU QED Image
-# http://wiki.qemu.org/Features/QED/Specification
-0	string/b	QED\0		QEMU QED Image
-
-# VDI Image
-64	string/b	\x7f\x10\xda\xbe	VDI Image
->68	string/b	\x01\x00\x01\x00	version 1.1
->0	string		>\0			(%s)
->368	lequad		x			 \b, %lld bytes
-
-0	string/b	Bochs\ Virtual\ HD\ Image	Bochs disk image,
->32	string	x				type %s,
->48	string	x				subtype %s
-
-0	lelong	0x02468ace			Bochs Sparse disk image
-
 # from http://filext.com by Derek M Jones <derek@knosof.co.uk>
 # from http://filext.com by Derek M Jones <derek@knosof.co.uk>
 # False positive with PPT (also currently this string is too long)
 # False positive with PPT (also currently this string is too long)
 #0	string/b	\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF\x09\x00\x06	Microsoft Installer
 #0	string/b	\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF\x09\x00\x06	Microsoft Installer
@@ -927,8 +849,8 @@
 # URL:	http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp
 # URL:	http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp
 # From: Morten Hustveit <morten@debian.org>
 # From: Morten Hustveit <morten@debian.org>
 0	string/b	DDS\040\174\000\000\000 Microsoft DirectDraw Surface (DDS),
 0	string/b	DDS\040\174\000\000\000 Microsoft DirectDraw Surface (DDS),
->16	lelong	>0			%hd x
->12	lelong	>0			%hd,
+>16	lelong	>0			%d x
+>12	lelong	>0			%d,
 >84	string	x			%.4s
 >84	string	x			%.4s
 
 
 # Type: Microsoft Document Imaging Format (.mdi)
 # Type: Microsoft Document Imaging Format (.mdi)

+ 1 - 1
magic/Magdir/msx

@@ -2,7 +2,7 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 # msx:  file(1) magic for the MSX Home Computer
 # msx:  file(1) magic for the MSX Home Computer
 # v1.1
 # v1.1
-# Fábio R. Schmidlin <sd-snatcher@users.sourceforge.net>
+# Fabio R. Schmidlin <sd-snatcher@users.sourceforge.net>
 
 
 ############## MSX Music file formats ##############
 ############## MSX Music file formats ##############
 
 

+ 2 - 2
magic/Magdir/natinst

@@ -1,6 +1,6 @@
 
 
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
-# $File: natinst,v 1.5 2013/02/06 14:18:52 christos Exp $
+# $File: natinst,v 1.6 2014/06/03 19:17:27 christos Exp $
 # natinst:  file(1) magic for National Instruments Code Files
 # natinst:  file(1) magic for National Instruments Code Files
 
 
 #
 #
@@ -12,7 +12,7 @@
 0       string          RSRC            National Instruments,
 0       string          RSRC            National Instruments,
 # Check if it's a LabVIEW File
 # Check if it's a LabVIEW File
 >8      string          LV              LabVIEW File,
 >8      string          LV              LabVIEW File,
-# Check wich kind of file is
+# Check which kind of file it is
 >>10    string          SB              Code Resource File, data
 >>10    string          SB              Code Resource File, data
 >>10    string          IN              Virtual Instrument Program, data
 >>10    string          IN              Virtual Instrument Program, data
 >>10    string          AR              VI Library, data
 >>10    string          AR              VI Library, data

+ 8 - 8
magic/Magdir/ncr

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: ncr,v 1.7 2009/09/19 16:28:11 christos Exp $
+# $File: ncr,v 1.8 2014/04/30 21:41:02 christos Exp $
 # ncr:  file(1) magic for NCR Tower objects
 # ncr:  file(1) magic for NCR Tower objects
 #
 #
 # contributed by
 # contributed by
@@ -11,27 +11,27 @@
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0410	pure executable
 >20	   beshort		0410	pure executable
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d
 0	beshort		000615	Tower/XP rel 2 object
 0	beshort		000615	Tower/XP rel 2 object
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0410	pure executable
 >20	   beshort		0410	pure executable
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d
 0	beshort		000620	Tower/XP rel 3 object
 0	beshort		000620	Tower/XP rel 3 object
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0410	pure executable
 >20	   beshort		0410	pure executable
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d
 0	beshort		000625	Tower/XP rel 3 object
 0	beshort		000625	Tower/XP rel 3 object
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0410	pure executable
 >20	   beshort		0410	pure executable
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d
 0	beshort		000630	Tower32/600/400 68020 object
 0	beshort		000630	Tower32/600/400 68020 object
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0410	pure executable
 >20	   beshort		0410	pure executable
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d
 0	beshort		000640	Tower32/800 68020
 0	beshort		000640	Tower32/800 68020
 >18	   beshort		&020000	w/68881 object
 >18	   beshort		&020000	w/68881 object
 >18	   beshort		&040000	compatible object
 >18	   beshort		&040000	compatible object
@@ -39,11 +39,11 @@
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0413	pure executable
 >20	   beshort		0413	pure executable
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d
 0	beshort		000645	Tower32/800 68010
 0	beshort		000645	Tower32/800 68010
 >18	   beshort		&040000	compatible object
 >18	   beshort		&040000	compatible object
 >18	   beshort		&060000 object
 >18	   beshort		&060000 object
 >20	   beshort		0407	executable
 >20	   beshort		0407	executable
 >20	   beshort		0413	pure executable
 >20	   beshort		0413	pure executable
 >12	   belong		>0	not stripped
 >12	   belong		>0	not stripped
->22	   beshort		>0	- version %ld
+>22	   beshort		>0	- version %d

+ 7 - 7
magic/Magdir/netbsd

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: netbsd,v 1.20 2013/01/09 22:37:24 christos Exp $
+# $File: netbsd,v 1.21 2014/03/29 15:40:34 christos Exp $
 # netbsd:  file(1) magic for NetBSD objects
 # netbsd:  file(1) magic for NetBSD objects
 #
 #
 # All new-style magic numbers are in network byte order.
 # All new-style magic numbers are in network byte order.
@@ -100,25 +100,25 @@
 0	belong&0377777777	045200507	a.out NetBSD/powerpc core
 0	belong&0377777777	045200507	a.out NetBSD/powerpc core
 >12	string			>\0		from '%s'
 >12	string			>\0		from '%s'
 
 
-0	belong&0377777777	042400413	a.out NetBSD/sparc demand paged
+0	belong&0377777777	042400413	a.out NetBSD/SPARC demand paged
 >0	byte			&0x80		
 >0	byte			&0x80		
 >>20	belong			<8192		shared library
 >>20	belong			<8192		shared library
 >>20	belong			=8192		dynamically linked executable
 >>20	belong			=8192		dynamically linked executable
 >>20	belong			>8192		dynamically linked executable
 >>20	belong			>8192		dynamically linked executable
 >0	byte			^0x80		executable
 >0	byte			^0x80		executable
 >16	belong			>0		not stripped
 >16	belong			>0		not stripped
-0	belong&0377777777	042400410	a.out NetBSD/sparc pure
+0	belong&0377777777	042400410	a.out NetBSD/SPARC pure
 >0	byte			&0x80		dynamically linked executable
 >0	byte			&0x80		dynamically linked executable
 >0	byte			^0x80		executable
 >0	byte			^0x80		executable
 >16	belong			>0		not stripped
 >16	belong			>0		not stripped
-0	belong&0377777777	042400407	a.out NetBSD/sparc
+0	belong&0377777777	042400407	a.out NetBSD/SPARC
 >0	byte			&0x80		dynamically linked executable
 >0	byte			&0x80		dynamically linked executable
 >0	byte			^0x80
 >0	byte			^0x80
 >>0	byte			&0x40		position independent
 >>0	byte			&0x40		position independent
 >>20	belong			!0		executable
 >>20	belong			!0		executable
 >>20	belong			=0		object file
 >>20	belong			=0		object file
 >16	belong			>0		not stripped
 >16	belong			>0		not stripped
-0	belong&0377777777	042400507	a.out NetBSD/sparc core
+0	belong&0377777777	042400507	a.out NetBSD/SPARC core
 >12	string			>\0		from '%s'
 >12	string			>\0		from '%s'
 >32	belong			!0		(signal %d)
 >32	belong			!0		(signal %d)
 
 
@@ -254,7 +254,7 @@
 >0	belong&0x03ff0000 0x00870000	\b, m68k BSD (8K pages)
 >0	belong&0x03ff0000 0x00870000	\b, m68k BSD (8K pages)
 >0	belong&0x03ff0000 0x00880000	\b, m68k BSD (4K pages)
 >0	belong&0x03ff0000 0x00880000	\b, m68k BSD (4K pages)
 >0	belong&0x03ff0000 0x00890000	\b, ns32532 BSD
 >0	belong&0x03ff0000 0x00890000	\b, ns32532 BSD
->0	belong&0x03ff0000 0x008a0000	\b, sparc/32 BSD
+>0	belong&0x03ff0000 0x008a0000	\b, SPARC/32 BSD
 >0	belong&0x03ff0000 0x008b0000	\b, pmax BSD
 >0	belong&0x03ff0000 0x008b0000	\b, pmax BSD
 >0	belong&0x03ff0000 0x008c0000	\b, vax BSD (1K pages)
 >0	belong&0x03ff0000 0x008c0000	\b, vax BSD (1K pages)
 >0	belong&0x03ff0000 0x008d0000	\b, alpha BSD
 >0	belong&0x03ff0000 0x008d0000	\b, alpha BSD
@@ -268,7 +268,7 @@
 >0	belong&0x03ff0000 0x00950000	\b, mips2 BSD
 >0	belong&0x03ff0000 0x00950000	\b, mips2 BSD
 >0	belong&0x03ff0000 0x00960000	\b, parisc BSD
 >0	belong&0x03ff0000 0x00960000	\b, parisc BSD
 >0	belong&0x03ff0000 0x00970000	\b, sh5/64 BSD
 >0	belong&0x03ff0000 0x00970000	\b, sh5/64 BSD
->0	belong&0x03ff0000 0x00980000	\b, sparc/64 BSD
+>0	belong&0x03ff0000 0x00980000	\b, SPARC/64 BSD
 >0	belong&0x03ff0000 0x00990000	\b, amd64 BSD
 >0	belong&0x03ff0000 0x00990000	\b, amd64 BSD
 >0	belong&0x03ff0000 0x009a0000	\b, hp200 (68010) BSD
 >0	belong&0x03ff0000 0x009a0000	\b, hp200 (68010) BSD
 >0	belong&0x03ff0000 0x009b0000	\b, hp300 (68020+68881) BSD
 >0	belong&0x03ff0000 0x009b0000	\b, hp300 (68020+68881) BSD

+ 1 - 1
magic/Magdir/nitpicker

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: nitpicker,v 1.4 2009/09/19 16:28:11 christos Exp $
+# $File: nitpicker,v 1.6 2014/04/30 21:41:02 christos Exp $
 # nitpicker:  file(1) magic for Flowfiles.
 # nitpicker:  file(1) magic for Flowfiles.
 # From: Christian Jachmann <C.Jachmann@gmx.net> http://www.nitpicker.de
 # From: Christian Jachmann <C.Jachmann@gmx.net> http://www.nitpicker.de
 0	string	NPFF	NItpicker Flow File 
 0	string	NPFF	NItpicker Flow File 

+ 2 - 2
magic/Magdir/oasis

@@ -1,9 +1,9 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: oasis,v 1.1 2011/03/15 02:09:38 christos Exp $
+# $File: oasis,v 1.2 2014/06/03 19:17:27 christos Exp $
 # OASIS
 # OASIS
 # Summary: OASIS stream file
 # Summary: OASIS stream file
-# Long descripton: Open Artwork System Interchange Standard
+# Long description: Open Artwork System Interchange Standard
 # File extension: .oas
 # File extension: .oas
 # Full name:	Ben Cowley (bcowley@broadcom.com)
 # Full name:	Ben Cowley (bcowley@broadcom.com)
 #		Philip Dixon (pdixon@broadcom.com)
 #		Philip Dixon (pdixon@broadcom.com)

+ 7 - 3
magic/Magdir/palm

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: palm,v 1.11 2013/12/31 19:18:02 christos Exp $
+# $File: palm,v 1.13 2014/03/30 21:40:08 christos Exp $
 # palm:	 file(1) magic for PalmOS {.prc,.pdb}: applications, docfiles, and hacks
 # palm:	 file(1) magic for PalmOS {.prc,.pdb}: applications, docfiles, and hacks
 #
 #
 # Brian Lalor <blalor@hcirisc.cs.binghamton.edu>
 # Brian Lalor <blalor@hcirisc.cs.binghamton.edu>
@@ -141,8 +141,12 @@
 >>(0x4E.L+1)	byte		x		%02d)
 >>(0x4E.L+1)	byte		x		%02d)
 
 
 # Palm OS .prc file types
 # Palm OS .prc file types
-60		string		libr		Palm OS dynamic library data
->0		string		>\0		"%s"
+60		string		libr
+# flags, only bit 0 or bit 6
+# http://en.wikipedia.org/wiki/PRC_%28Palm_OS%29
+# http://web.mit.edu/tytso/www/pilot/prc-format.html
+>0x20		beshort&0xffbe	0
+>>0		string		>\0		Palm OS dynamic library data "%s"
 60		string		ptch		Palm OS operating system patch data
 60		string		ptch		Palm OS operating system patch data
 >0		string		>\0		"%s"
 >0		string		>\0		"%s"
 
 

+ 4 - 4
magic/Magdir/pdp

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: pdp,v 1.9 2013/04/19 20:11:43 christos Exp $
+# $File: pdp,v 1.10 2014/04/30 21:41:02 christos Exp $
 # pdp:  file(1) magic for PDP-11 executable/object and APL workspace
 # pdp:  file(1) magic for PDP-11 executable/object and APL workspace
 #
 #
 0	lelong		0101555		PDP-11 single precision APL workspace
 0	lelong		0101555		PDP-11 single precision APL workspace
@@ -10,7 +10,7 @@
 #
 #
 0	leshort		0407		PDP-11 executable
 0	leshort		0407		PDP-11 executable
 >8	leshort		>0		not stripped
 >8	leshort		>0		not stripped
->15	byte		>0		- version %ld
+>15	byte		>0		- version %d
 
 
 # updated by Joerg Jenderek at Mar 2013
 # updated by Joerg Jenderek at Mar 2013
 # GRR: line below too general as it catches also Windows precompiled setup information *.PNF
 # GRR: line below too general as it catches also Windows precompiled setup information *.PNF
@@ -23,11 +23,11 @@
 
 
 0	leshort		0410		PDP-11 pure executable
 0	leshort		0410		PDP-11 pure executable
 >8	leshort		>0		not stripped
 >8	leshort		>0		not stripped
->15	byte		>0		- version %ld
+>15	byte		>0		- version %d
 
 
 0	leshort		0411		PDP-11 separate I&D executable
 0	leshort		0411		PDP-11 separate I&D executable
 >8	leshort		>0		not stripped
 >8	leshort		>0		not stripped
->15	byte		>0		- version %ld
+>15	byte		>0		- version %d
 
 
 0	leshort		0437		PDP-11 kernel overlay
 0	leshort		0437		PDP-11 kernel overlay
 
 

+ 32 - 1
magic/Magdir/perl

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: perl,v 1.21 2013/12/08 23:33:18 christos Exp $
+# $File: perl,v 1.22 2014/04/28 12:04:35 christos Exp $
 # perl:  file(1) magic for Larry Wall's perl language.
 # perl:  file(1) magic for Larry Wall's perl language.
 #
 #
 # The `eval' lines recognizes an outrageously clever hack.
 # The `eval' lines recognizes an outrageously clever hack.
@@ -57,3 +57,34 @@
 >>4	byte	=5	(major 2)
 >>4	byte	=5	(major 2)
 >>4	byte	=4	(major 2)
 >>4	byte	=4	(major 2)
 >>5	byte	>0	(minor %d)
 >>5	byte	>0	(minor %d)
+
+# This is Debian #742949 by Zefram <zefram@fysh.org>:
+# -----------------------------------------------------------
+# The Perl module Hash::SharedMem
+# <https://metacpan.org/release/Hash-SharedMem> defines a file format
+# for a key/value store.  Details of the file format are in the "DESIGN"
+# file in the module distribution.  Magic:
+0	bequad	=0xa58afd185cbf5af7	Hash::SharedMem master file, big-endian
+>8	bequad	<0x1000000
+>>15	byte	>2	\b, line size 2^%d byte
+>>14	byte	>2	\b, page size 2^%d byte
+>>13	byte	&1
+>>>13	byte	>1	\b, max fanout %d
+0	lequad	=0xa58afd185cbf5af7	Hash::SharedMem master file, little-endian
+>8	lequad	<0x1000000
+>>8	byte	>2	\b, line size 2^%d byte
+>>9	byte	>2	\b, page size 2^%d byte
+>>10	byte	&1
+>>>10	byte	>1	\b, max fanout %d
+0	bequad	=0xc693dac5ed5e47c2	Hash::SharedMem data file, big-endian
+>8	bequad	<0x1000000
+>>15	byte	>2	\b, line size 2^%d byte
+>>14	byte	>2	\b, page size 2^%d byte
+>>13	byte	&1
+>>>13	byte	>1	\b, max fanout %d
+0	lequad	=0xc693dac5ed5e47c2	Hash::SharedMem data file, little-endian
+>8	lequad	<0x1000000
+>>8	byte	>2	\b, line size 2^%d byte
+>>9	byte	>2	\b, page size 2^%d byte
+>>10	byte	&1
+>>>10	byte	>1	\b, max fanout %d

+ 19 - 3
magic/Magdir/printer

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: printer,v 1.25 2011/05/20 23:31:46 christos Exp $
+# $File: printer,v 1.26 2014/04/12 14:51:52 christos Exp $
 # printer:  file(1) magic for printer-formatted files
 # printer:  file(1) magic for printer-formatted files
 #
 #
 
 
@@ -68,6 +68,22 @@
 0	string		\033%-12345X@PJL
 0	string		\033%-12345X@PJL
 >&0	search/10000	%!			PJL encapsulated PostScript document text
 >&0	search/10000	%!			PJL encapsulated PostScript document text
 
 
+# Rick Richardson <rickrich@gmail.com>
+
+# For Fuji-Xerox Printers - HBPL stands for Host Based Printer Language
+# For Oki Data Printers - HIPERC
+# For Konica Minolta Printers - LAVAFLOW
+# For Samsung Printers - QPDL
+# For HP Printers - ZJS stands for Zenographics ZJStream
+0	string		\033%-12345X@PJL	HP Printer Job Language data
+>0	search/10000	@PJL\ ENTER\ LANGUAGE=HBPL	- HBPL
+>0	search/10000	@PJL\ ENTER\ LANGUAGE=HIPERC	- Oki Data HIPERC
+>0	search/10000	@PJL\ ENTER\ LANGUAGE=LAVAFLOW	- Konica Minolta LAVAFLOW
+>0	search/10000	@PJL\ ENTER\ LANGUAGE=QPDL	- Samsung QPDL
+>0	search/10000	@PJL\ ENTER\ LANGUAGE\ =\ QPDL	- Samsung QPDL
+>0	search/10000	@PJL\ ENTER\ LANGUAGE=ZJS	- HP ZJS
+
+
 # HP Printer Control Language, Daniel Quinlan (quinlan@yggdrasil.com)
 # HP Printer Control Language, Daniel Quinlan (quinlan@yggdrasil.com)
 0	string		\033E\033	HP PCL printer data
 0	string		\033E\033	HP PCL printer data
 >3	string		\&l0A		- default page size
 >3	string		\&l0A		- default page size
@@ -108,7 +124,7 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 # zenographics:  file(1) magic for Zenographics ZjStream printer data
 # zenographics:  file(1) magic for Zenographics ZjStream printer data
-# Rick Richardson  rickr@mn.rr.com
+# Rick Richardson <rickrich@gmail.com>
 0	string		JZJZ
 0	string		JZJZ
 >0x12	string		ZZ		Zenographics ZjStream printer data (big-endian)
 >0x12	string		ZZ		Zenographics ZjStream printer data (big-endian)
 0	string		ZJZJ
 0	string		ZJZJ
@@ -117,7 +133,7 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 # Oak Technologies printer stream
 # Oak Technologies printer stream
-# Rick Richardson <rickr@mn.rr.com>
+# Rick Richardson <rickrich@gmail.com>
 0       string          OAK
 0       string          OAK
 >0x07	byte		0
 >0x07	byte		0
 >0x0b	byte		0	Oak Technologies printer stream
 >0x0b	byte		0	Oak Technologies printer stream

+ 2 - 2
magic/Magdir/python

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: python,v 1.24 2014/02/15 01:30:52 christos Exp $
+# $File: python,v 1.25 2014/05/06 16:08:32 christos Exp $
 # python:  file(1) magic for python
 # python:  file(1) magic for python
 #
 #
 # Outlook puts """ too for urgent messages
 # Outlook puts """ too for urgent messages
@@ -63,5 +63,5 @@
 
 
 # def name(args, args):
 # def name(args, args):
 0	regex	 \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100}
 0	regex	 \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100}
->&0	regex	\ {0,50}\\(([a-zA-Z]|,|\ ){1,500}\\):$ Python script text executable
+>&0	regex	\ {0,50}\\(([a-zA-Z]|,|\ ){1,255}\\):$ Python script text executable
 !:mime text/x-python
 !:mime text/x-python

+ 3 - 3
magic/Magdir/riff

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: riff,v 1.26 2014/03/06 18:55:09 christos Exp $
+# $File: riff,v 1.27 2014/04/30 21:41:02 christos Exp $
 # riff:  file(1) magic for RIFF format
 # riff:  file(1) magic for RIFF format
 # See
 # See
 #
 #
@@ -88,8 +88,8 @@
 !:mime	video/x-msvideo
 !:mime	video/x-msvideo
 >>12    string          LIST
 >>12    string          LIST
 >>>20   string          hdrlavih
 >>>20   string          hdrlavih
->>>>&36 lelong          x               \b, %lu x
->>>>&40 lelong          x               %lu,
+>>>>&36 lelong          x               \b, %u x
+>>>>&40 lelong          x               %u,
 >>>>&4  lelong          >1000000        <1 fps,
 >>>>&4  lelong          >1000000        <1 fps,
 >>>>&4  lelong          1000000         1.00 fps,
 >>>>&4  lelong          1000000         1.00 fps,
 >>>>&4  lelong          500000          2.00 fps,
 >>>>&4  lelong          500000          2.00 fps,

+ 6 - 6
magic/Magdir/scientific

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: scientific,v 1.8 2014/01/06 17:46:23 rrt Exp $
+# $File: scientific,v 1.9 2014/06/03 19:01:34 christos Exp $
 # scientific:  file(1) magic for scientific formats 
 # scientific:  file(1) magic for scientific formats 
 #
 #
 # From: Joe Krahn <krahn@niehs.nih.gov>
 # From: Joe Krahn <krahn@niehs.nih.gov>
@@ -91,12 +91,12 @@
 # uppercase letters. However, examples have been seen without the date string,
 # uppercase letters. However, examples have been seen without the date string,
 # e.g., the example on the chemime site.
 # e.g., the example on the chemime site.
 0	string	HEADER\ \ \ \ 
 0	string	HEADER\ \ \ \ 
->&0	regex/1	\^.{40}
->>&0	regex/1	[0-9]{2}-[A-Z]{3}-[0-9]{2}\ {3}
->>>&0	regex/1s	[A-Z0-9]{4}.{14}$
->>>>&0	regex/1	[A-Z0-9]{4}	Protein Data Bank data, ID Code %s
+>&0	regex/1l	\^.{40}
+>>&0	regex/1l	[0-9]{2}-[A-Z]{3}-[0-9]{2}\ {3}
+>>>&0	regex/1ls	[A-Z0-9]{4}.{14}$
+>>>>&0	regex/1l	[A-Z0-9]{4}	Protein Data Bank data, ID Code %s
 !:mime	chemical/x-pdb
 !:mime	chemical/x-pdb
->>>>0	regex/1	[0-9]{2}-[A-Z]{3}-[0-9]{2}	\b, %s
+>>>>0	regex/1l	[0-9]{2}-[A-Z]{3}-[0-9]{2}	\b, %s
 
 
 # Type:	GDSII Stream file
 # Type:	GDSII Stream file
 0	belong	0x00060002	GDSII Stream file
 0	belong	0x00060002	GDSII Stream file

+ 19 - 9
magic/Magdir/sequent

@@ -1,35 +1,45 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: sequent,v 1.8 2009/09/19 16:28:12 christos Exp $
+# $File: sequent,v 1.11 2014/06/02 19:27:54 christos Exp $
 # sequent:  file(1) magic for Sequent machines
 # sequent:  file(1) magic for Sequent machines
 #
 #
 # Sequent information updated by Don Dwiggins <atsun!dwiggins>.
 # Sequent information updated by Don Dwiggins <atsun!dwiggins>.
 # For Sequent's multiprocessor systems (incomplete).
 # For Sequent's multiprocessor systems (incomplete).
 0	lelong	0x00ea        	BALANCE NS32000 .o
 0	lelong	0x00ea        	BALANCE NS32000 .o
 >16	lelong	>0		not stripped
 >16	lelong	>0		not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 0	lelong	0x10ea        	BALANCE NS32000 executable (0 @ 0)
 0	lelong	0x10ea        	BALANCE NS32000 executable (0 @ 0)
 >16	lelong  >0            	not stripped
 >16	lelong  >0            	not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 0	lelong	0x20ea        	BALANCE NS32000 executable (invalid @ 0)
 0	lelong	0x20ea        	BALANCE NS32000 executable (invalid @ 0)
 >16	lelong  >0            	not stripped
 >16	lelong  >0            	not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 0	lelong	0x30ea        	BALANCE NS32000 standalone executable
 0	lelong	0x30ea        	BALANCE NS32000 standalone executable
 >16	lelong  >0          	not stripped
 >16	lelong  >0          	not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 #
 #
 # Symmetry information added by Jason Merrill <jason@jarthur.claremont.edu>.
 # Symmetry information added by Jason Merrill <jason@jarthur.claremont.edu>.
 # Symmetry magic nums will not be reached if DOS COM comes before them;
 # Symmetry magic nums will not be reached if DOS COM comes before them;
 # byte 0xeb is matched before these get a chance.
 # byte 0xeb is matched before these get a chance.
 0	leshort	0x12eb		SYMMETRY i386 .o
 0	leshort	0x12eb		SYMMETRY i386 .o
 >16	lelong	>0		not stripped
 >16	lelong	>0		not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 0	leshort	0x22eb		SYMMETRY i386 executable (0 @ 0)
 0	leshort	0x22eb		SYMMETRY i386 executable (0 @ 0)
 >16	lelong	>0		not stripped
 >16	lelong	>0		not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 0	leshort	0x32eb		SYMMETRY i386 executable (invalid @ 0)
 0	leshort	0x32eb		SYMMETRY i386 executable (invalid @ 0)
 >16	lelong	>0		not stripped
 >16	lelong	>0		not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
 0	leshort	0x42eb		SYMMETRY i386 standalone executable
 0	leshort	0x42eb		SYMMETRY i386 standalone executable
 >16	lelong	>0		not stripped
 >16	lelong	>0		not stripped
->124	lelong	>0		version %ld
+>124	lelong	>0		version %d
+# http://en.wikipedia.org/wiki/Sequent_Computer_Systems
+# below test line conflicts with MS-DOS 2.11 floppies and Acronis loader
+#0	leshort	0x42eb		SYMMETRY i386 standalone executable
+0	leshort	0x42eb		
+# skip unlike negative version
+>124	lelong	>-1		
+# assuming version 28867614 is very low probable
+>>124	lelong	!28867614	SYMMETRY i386 standalone executable
+>>>16	lelong	>0		not stripped
+>>>124	lelong	>0		version %d

+ 24 - 0
magic/Magdir/sereal

@@ -0,0 +1,24 @@
+#------------------------------------------------------------------------------
+# $File: sereal,v 1.1 2014/05/14 23:04:59 christos Exp $
+# sereal: file(1) magic the Sereal binary serialization format
+#
+# From: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+#
+# See the specification of the format at
+# https://github.com/Sereal/Sereal/blob/master/sereal_spec.pod#document-header-format
+#
+# I'd have liked to do the byte&0xF0 matching against 0, 1, 2 ... by
+# doing (byte&0xF0)>>4 here, but unfortunately that's not
+# supported. So when we print out a message about an unknown format
+# we'll print out e.g. 0x30 instead of the more human-readable
+# 0x30>>4.
+#
+# See https://github.com/Sereal/Sereal/commit/35372ae01d in the
+# Sereal.git repository for test Sereal data.
+0      string             \=srl   Sereal data
+!:mime application/sereal
+>4     byte&0x0F          x       (version %d,
+>4     byte&0xF0          0x00    uncompressed)
+>4     byte&0xF0          0x10    compressed with non-incremental Snappy)
+>4     byte&0xF0          0x20    compressed with incremental Snappy)
+>4     byte&0xF0          >0x20   unknown subformat, flag: %d>>4)

+ 9 - 9
magic/Magdir/sgi

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: sgi,v 1.20 2014/03/10 00:53:38 christos Exp $
+# $File: sgi,v 1.21 2014/04/30 21:41:02 christos Exp $
 # sgi:  file(1) magic for Silicon Graphics operating systems and applications
 # sgi:  file(1) magic for Silicon Graphics operating systems and applications
 #
 #
 # Executable images are handled either in aout (for old-style a.out
 # Executable images are handled either in aout (for old-style a.out
@@ -17,16 +17,16 @@
 
 
 0	beshort	0x0506		IRIS Showcase file
 0	beshort	0x0506		IRIS Showcase file
 >2	byte	0x49		-
 >2	byte	0x49		-
->3	byte	x		- version %ld
+>3	byte	x		- version %d
 0	beshort	0x0226		IRIS Showcase template
 0	beshort	0x0226		IRIS Showcase template
 >2	byte	0x63		-
 >2	byte	0x63		-
->3	byte	x		- version %ld
+>3	byte	x		- version %d
 0	belong	0x5343464d	IRIS Showcase file
 0	belong	0x5343464d	IRIS Showcase file
->4	byte	x		- version %ld
+>4	byte	x		- version %d
 0	belong	0x5443464d	IRIS Showcase template
 0	belong	0x5443464d	IRIS Showcase template
->4	byte	x		- version %ld
+>4	byte	x		- version %d
 0	belong	0xdeadbabe	IRIX Parallel Arena
 0	belong	0xdeadbabe	IRIX Parallel Arena
->8	belong	>0		- version %ld
+>8	belong	>0		- version %d
 
 
 # core files
 # core files
 #
 #
@@ -49,7 +49,7 @@
 # Trusted IRIX info
 # Trusted IRIX info
 0	string	SGIAUDIT	SGI Audit file
 0	string	SGIAUDIT	SGI Audit file
 >8	byte	x		- version %d
 >8	byte	x		- version %d
->9	byte	x		\b.%ld
+>9	byte	x		\b.%d
 #
 #
 0	string	WNGZWZSC	Wingz compiled script
 0	string	WNGZWZSC	Wingz compiled script
 0	string	WNGZWZSS	Wingz spreadsheet
 0	string	WNGZWZSS	Wingz spreadsheet
@@ -82,11 +82,11 @@
 #>20	lelong	-2				temporal index
 #>20	lelong	-2				temporal index
 #>20	lelong	-1				metadata
 #>20	lelong	-1				metadata
 #>20	lelong	0				log volume #0
 #>20	lelong	0				log volume #0
-#>20	lelong	>0				log volume #%ld
+#>20	lelong	>0				log volume #%d
 >20	belong	-2				temporal index
 >20	belong	-2				temporal index
 >20	belong	-1				metadata
 >20	belong	-1				metadata
 >20	belong	0				log volume #0
 >20	belong	0				log volume #0
->20	belong	>0				log volume #%ld
+>20	belong	>0				log volume #%d
 >24	string	>\0				host: %s
 >24	string	>\0				host: %s
 0	string	PCPFolio			PCP
 0	string	PCPFolio			PCP
 >9	string	Version:			Archive Folio
 >9	string	Version:			Archive Folio

+ 2 - 2
magic/Magdir/sharc

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------
 #------------------------------------------------------------------------
-# $File: sharc,v 1.6 2009/09/19 16:28:12 christos Exp $
+# $File: sharc,v 1.7 2014/04/30 21:41:02 christos Exp $
 # file(1) magic for sharc files
 # file(1) magic for sharc files
 #
 #
 # SHARC DSP, MIDI SysEx and RiscOS filetype definitions added by 
 # SHARC DSP, MIDI SysEx and RiscOS filetype definitions added by 
@@ -19,5 +19,5 @@
 0	string			.system		SHARC architecture file
 0	string			.system		SHARC architecture file
 
 
 0	leshort			0x521C		SHARC COFF binary
 0	leshort			0x521C		SHARC COFF binary
->2	leshort			>1		, %hd sections
+>2	leshort			>1		, %d sections
 >>12	lelong			>0		, not stripped
 >>12	lelong			>0		, not stripped

+ 2 - 2
magic/Magdir/sql

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: sql,v 1.13 2013/08/27 04:02:33 christos Exp $
+# $File: sql,v 1.15 2014/04/30 21:41:02 christos Exp $
 # sql:  file(1) magic for SQL files
 # sql:  file(1) magic for SQL files
 #
 #
 # From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
 # From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
@@ -69,7 +69,7 @@
 # SQLite Write-Ahead Log from SQLite version >= 3.7.0
 # SQLite Write-Ahead Log from SQLite version >= 3.7.0
 # http://www.sqlite.org/fileformat.html#walformat
 # http://www.sqlite.org/fileformat.html#walformat
 0	belong&0xfffffffe	0x377f0682	SQLite Write-Ahead Log,
 0	belong&0xfffffffe	0x377f0682	SQLite Write-Ahead Log,
->4	belong	x	version %ld
+>4	belong	x	version %d
 
 
 # SQLite Rollback Journal
 # SQLite Rollback Journal
 # http://www.sqlite.org/fileformat.html#rollbackjournal
 # http://www.sqlite.org/fileformat.html#rollbackjournal

+ 19 - 19
magic/Magdir/sun

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: sun,v 1.25 2013/01/09 22:37:24 christos Exp $
+# $File: sun,v 1.27 2014/04/30 21:41:02 christos Exp $
 # sun:  file(1) magic for Sun machines
 # sun:  file(1) magic for Sun machines
 #
 #
 # Values for big-endian Sun (MC680x0, SPARC) binaries on pre-5.x
 # Values for big-endian Sun (MC680x0, SPARC) binaries on pre-5.x
@@ -9,7 +9,7 @@
 # are in aout, as they're indistinguishable from other big-endian
 # are in aout, as they're indistinguishable from other big-endian
 # 32-bit a.out files.
 # 32-bit a.out files.
 #
 #
-0	belong&077777777	0600413		a.out SunOS sparc demand paged
+0	belong&077777777	0600413		a.out SunOS SPARC demand paged
 >0	byte		&0x80
 >0	byte		&0x80
 >>20	belong		<4096		shared library
 >>20	belong		<4096		shared library
 >>20	belong		=4096		dynamically linked executable
 >>20	belong		=4096		dynamically linked executable
@@ -17,12 +17,12 @@
 >0	byte		^0x80		executable
 >0	byte		^0x80		executable
 >16	belong		>0		not stripped
 >16	belong		>0		not stripped
 
 
-0	belong&077777777	0600410		a.out SunOS sparc pure
+0	belong&077777777	0600410		a.out SunOS SPARC pure
 >0	byte		&0x80		dynamically linked executable
 >0	byte		&0x80		dynamically linked executable
 >0	byte		^0x80		executable
 >0	byte		^0x80		executable
 >16	belong		>0		not stripped
 >16	belong		>0		not stripped
 
 
-0	belong&077777777	0600407		a.out SunOS sparc
+0	belong&077777777	0600407		a.out SunOS SPARC
 >0	byte		&0x80		dynamically linked executable
 >0	byte		&0x80		dynamically linked executable
 >0	byte		^0x80		executable
 >0	byte		^0x80		executable
 >16	belong		>0		not stripped
 >16	belong		>0		not stripped
@@ -97,7 +97,7 @@
 # which is the IANA registry of Snoop datalink types)
 # which is the IANA registry of Snoop datalink types)
 #
 #
 0	string		snoop		Snoop capture file
 0	string		snoop		Snoop capture file
->8	belong		>0		- version %ld
+>8	belong		>0		- version %d
 >12	belong		0		(IEEE 802.3)
 >12	belong		0		(IEEE 802.3)
 >12	belong		1		(IEEE 802.4)
 >12	belong		1		(IEEE 802.4)
 >12	belong		2		(IEEE 802.5)
 >12	belong		2		(IEEE 802.5)
@@ -108,24 +108,24 @@
 >12	belong		7		(IBM channel-to-channel adapter)
 >12	belong		7		(IBM channel-to-channel adapter)
 >12	belong		8		(FDDI)
 >12	belong		8		(FDDI)
 >12	belong		9		(Other)
 >12	belong		9		(Other)
->12	belong		10		(type %ld)
->12	belong		11		(type %ld)
->12	belong		12		(type %ld)
->12	belong		13		(type %ld)
->12	belong		14		(type %ld)
->12	belong		15		(type %ld)
+>12	belong		10		(type %d)
+>12	belong		11		(type %d)
+>12	belong		12		(type %d)
+>12	belong		13		(type %d)
+>12	belong		14		(type %d)
+>12	belong		15		(type %d)
 >12	belong		16		(Fibre Channel)
 >12	belong		16		(Fibre Channel)
 >12	belong		17		(ATM)
 >12	belong		17		(ATM)
 >12	belong		18		(ATM Classical IP)
 >12	belong		18		(ATM Classical IP)
->12	belong		19		(type %ld)
->12	belong		20		(type %ld)
->12	belong		21		(type %ld)
->12	belong		22		(type %ld)
->12	belong		23		(type %ld)
->12	belong		24		(type %ld)
->12	belong		25		(type %ld)
+>12	belong		19		(type %d)
+>12	belong		20		(type %d)
+>12	belong		21		(type %d)
+>12	belong		22		(type %d)
+>12	belong		23		(type %d)
+>12	belong		24		(type %d)
+>12	belong		25		(type %d)
 >12	belong		26		(IP over Infiniband)
 >12	belong		26		(IP over Infiniband)
->12	belong		>26		(type %ld)
+>12	belong		>26		(type %d)
 
 
 #---------------------------------------------------------------------------
 #---------------------------------------------------------------------------
 # The following entries have been tested by Duncan Laurie <duncan@sun.com> (a
 # The following entries have been tested by Duncan Laurie <duncan@sun.com> (a

+ 1 - 1
magic/Magdir/symbos

@@ -2,7 +2,7 @@
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 # msx:  file(1) magic for the SymbOS operating system
 # msx:  file(1) magic for the SymbOS operating system
 # http://www.symbos.de
 # http://www.symbos.de
-# Fábio R. Schmidlin <frs@pop.com.br>
+# Fabio R. Schmidlin <frs@pop.com.br>
 
 
 # SymbOS EXE file
 # SymbOS EXE file
 0x30	string		SymExe		SymbOS executable
 0x30	string		SymExe		SymbOS executable

+ 2 - 2
magic/Magdir/sysex

@@ -1,9 +1,9 @@
 
 
 #------------------------------------------------------------------------
 #------------------------------------------------------------------------
-# $File: sysex,v 1.7 2013/09/16 15:12:42 christos Exp $
+# $File: sysex,v 1.8 2014/06/03 19:17:27 christos Exp $
 # sysex: file(1) magic for MIDI sysex files
 # sysex: file(1) magic for MIDI sysex files
 #
 #
-# GRR: orginal 1 byte test at offset was too general as it catches also many FATs of DOS filesystems
+# GRR: original 1 byte test at offset was too general as it catches also many FATs of DOS filesystems
 # where real SYStem EXclusive messages at offset 1 are limited to seven bits
 # where real SYStem EXclusive messages at offset 1 are limited to seven bits
 # http://en.wikipedia.org/wiki/MIDI
 # http://en.wikipedia.org/wiki/MIDI
 0	ubeshort&0xFF80		0xF000		SysEx File -
 0	ubeshort&0xFF80		0xF000		SysEx File -

+ 2 - 2
magic/Magdir/ti-8x

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: ti-8x,v 1.6 2009/09/19 16:28:12 christos Exp $
+# $File: ti-8x,v 1.7 2014/04/30 21:41:02 christos Exp $
 # ti-8x: file(1) magic for the TI-8x and TI-9x Graphing Calculators.
 # ti-8x: file(1) magic for the TI-8x and TI-9x Graphing Calculators.
 #
 #
 # From: Ryan McGuire (rmcguire@freenet.columbus.oh.us).
 # From: Ryan McGuire (rmcguire@freenet.columbus.oh.us).
@@ -222,7 +222,7 @@
 >49		byte		0x24		type: application,
 >49		byte		0x24		type: application,
 >49		byte		0x25		type: certificate,
 >49		byte		0x25		type: certificate,
 >49		byte		0x3e		type: license,
 >49		byte		0x3e		type: license,
->74		lelong		>0		size: %ld bytes
+>74		lelong		>0		size: %d bytes
 
 
 # VTi & TiEmu skins (TI Graphing Calculators).
 # VTi & TiEmu skins (TI Graphing Calculators).
 # From: Romain Lievin (roms@lpg.ticalc.org).
 # From: Romain Lievin (roms@lpg.ticalc.org).

+ 3 - 3
magic/Magdir/troff

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: troff,v 1.10 2009/09/19 16:28:12 christos Exp $
+# $File: troff,v 1.11 2014/06/03 19:01:34 christos Exp $
 # troff:  file(1) magic for *roff
 # troff:  file(1) magic for *roff
 #
 #
 # updated by Daniel Quinlan (quinlan@yggdrasil.com)
 # updated by Daniel Quinlan (quinlan@yggdrasil.com)
@@ -16,9 +16,9 @@
 !:mime	text/troff
 !:mime	text/troff
 0	search/1	'''		troff or preprocessor input text
 0	search/1	'''		troff or preprocessor input text
 !:mime	text/troff
 !:mime	text/troff
-0	regex/20	\^\\.[A-Za-z0-9][A-Za-z0-9][\ \t]	troff or preprocessor input text
+0	regex/20l	\^\\.[A-Za-z0-9][A-Za-z0-9][\ \t]	troff or preprocessor input text
 !:mime	text/troff
 !:mime	text/troff
-0	regex/20	\^\\.[A-Za-z0-9][A-Za-z0-9]$	troff or preprocessor input text
+0	regex/20l	\^\\.[A-Za-z0-9][A-Za-z0-9]$	troff or preprocessor input text
 !:mime	text/troff
 !:mime	text/troff
 
 
 # ditroff intermediate output text
 # ditroff intermediate output text

+ 1 - 1
magic/Magdir/uterus

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: uterus,v 1.1 2012/12/18 18:53:32 christos Exp $
+# $File: uterus,v 1.3 2014/04/30 21:41:02 christos Exp $
 # file(1) magic for uterus files
 # file(1) magic for uterus files
 # http://freecode.com/projects/uterus
 # http://freecode.com/projects/uterus
 #
 #

+ 2 - 2
magic/Magdir/varied.out

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: varied.out,v 1.22 2010/07/02 00:06:27 christos Exp $
+# $File: varied.out,v 1.23 2014/04/30 21:41:02 christos Exp $
 # varied.out:  file(1) magic for various USG systems
 # varied.out:  file(1) magic for various USG systems
 #
 #
 #	Herewith many of the object file formats used by USG systems.
 #	Herewith many of the object file formats used by USG systems.
@@ -26,7 +26,7 @@
 >7      string          >\0     version '%s'
 >7      string          >\0     version '%s'
 # gnu gmon magic From: Eugen Dedu <dedu@ese-metz.fr>
 # gnu gmon magic From: Eugen Dedu <dedu@ese-metz.fr>
 0	string		gmon		GNU prof performance data
 0	string		gmon		GNU prof performance data
->4	long		x		- version %ld
+>4	long		x		- version %d
 # From: Dave Pearson <davep@davep.org>
 # From: Dave Pearson <davep@davep.org>
 # Harbour <URL:http://harbour-project.org/> HRB files.
 # Harbour <URL:http://harbour-project.org/> HRB files.
 0	string		\xc0HRB		Harbour HRB file
 0	string		\xc0HRB		Harbour HRB file

+ 3 - 3
magic/Magdir/vax

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: vax,v 1.8 2013/01/09 22:37:24 christos Exp $
+# $File: vax,v 1.9 2014/04/30 21:41:02 christos Exp $
 # vax:  file(1) magic for VAX executable/object and APL workspace
 # vax:  file(1) magic for VAX executable/object and APL workspace
 #
 #
 0	lelong		0101557		VAX single precision APL workspace
 0	lelong		0101557		VAX single precision APL workspace
@@ -21,7 +21,7 @@
 #
 #
 0	leshort		0570		VAX COFF executable
 0	leshort		0570		VAX COFF executable
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
->22	leshort		>0		- version %ld
+>22	leshort		>0		- version %d
 0	leshort		0575		VAX COFF pure executable
 0	leshort		0575		VAX COFF pure executable
 >12	lelong		>0		not stripped
 >12	lelong		>0		not stripped
->22	leshort		>0		- version %ld
+>22	leshort		>0		- version %d

+ 104 - 8
magic/Magdir/virtual

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: virtual,v 1.3 2014/03/03 14:19:46 christos Exp $
+# $File: virtual,v 1.6 2014/05/07 21:25:41 christos Exp $
 # From: James Nobis <quel@quelrod.net>
 # From: James Nobis <quel@quelrod.net>
 # Microsoft hard disk images for:
 # Microsoft hard disk images for:
 # Virtual Server
 # Virtual Server
@@ -9,13 +9,6 @@
 # .vhd
 # .vhd
 0	string	conectix	Microsoft Disk Image, Virtual Server or Virtual PC
 0	string	conectix	Microsoft Disk Image, Virtual Server or Virtual PC
 
 
-# Sun xVM VirtualBox Disk Image
-# From: Richard W.M. Jones <rich@annexia.org>
-# VirtualBox Disk Image
-0x40	ulelong		0xbeda107f	VirtualBox Disk Image
->0x44	uleshort	>0		\b, major %u
->0x46	uleshort	>0		\b, minor %u
-
 # libvirt
 # libvirt
 # From: Philipp Hahn <hahn@univention.de>
 # From: Philipp Hahn <hahn@univention.de>
 0	string	LibvirtQemudSave	Libvirt QEMU Suspend Image
 0	string	LibvirtQemudSave	Libvirt QEMU Suspend Image
@@ -25,3 +18,106 @@
 >0x1c	lelong	1	\b, compressed
 >0x1c	lelong	1	\b, compressed
 
 
 0	string	LibvirtQemudPart	Libvirt QEMU partial Suspend Image
 0	string	LibvirtQemudPart	Libvirt QEMU partial Suspend Image
+# From: Alex Beregszaszi <alex@fsn.hu>
+0	string/b	COWD		VMWare3
+>4	byte	3		disk image
+>>32	lelong	x		(%d/
+>>36	lelong	x		\b%d/
+>>40	lelong	x		\b%d)
+>4	byte	2		undoable disk image
+>>32	string	>\0		(%s)
+
+0	string/b	VMDK		 VMware4 disk image
+0	string/b	KDMV		 VMware4 disk image
+
+#--------------------------------------------------------------------
+# Qemu Emulator Images
+# Lines written by Friedrich Schwittay (f.schwittay@yousable.de)
+# Updated by Adam Buchbinder (adam.buchbinder@gmail.com)
+# Made by reading sources, reading documentation, and doing trial and error
+# on existing QCOW files
+0	string/b	QFI\xFB	QEMU QCOW Image
+
+# Uncomment the following line to display Magic (only used for debugging
+# this magic number)
+#>0	string/b	x	, Magic: %s
+
+# There are currently 2 Versions: "1" and "2".
+# http://www.gnome.org/~markmc/qcow-image-format-version-1.html
+>4	belong	1	(v1)
+
+# Using the existence of the Backing File Offset to determine whether
+# to read Backing File Information
+>>12	belong	 >0	 \b, has backing file (
+# Note that this isn't a null-terminated string; the length is actually
+# (16.L). Assuming a null-terminated string happens to work usually, but it
+# may spew junk until it reaches a \0 in some cases.
+>>>(12.L)	 string >\0	\bpath %s
+
+# Modification time of the Backing File
+# Really useful if you want to know if your backing
+# file is still usable together with this image
+>>>>20	bedate >0	\b, mtime %s)
+>>>>20	default x	\b)
+
+# Size is stored in bytes in a big-endian u64.
+>>24	bequad	x	 \b, %lld bytes
+
+# 1 for AES encryption, 0 for none.
+>>36	belong	1	\b, AES-encrypted
+
+# http://www.gnome.org/~markmc/qcow-image-format.html
+>4	belong	2	(v2)
+# Using the existence of the Backing File Offset to determine whether
+# to read Backing File Information
+>>8	bequad  >0	 \b, has backing file
+# Note that this isn't a null-terminated string; the length is actually
+# (16.L). Assuming a null-terminated string happens to work usually, but it
+# may spew junk until it reaches a \0 in some cases. Also, since there's no
+# .Q modifier, we just use the bottom four bytes as an offset. Note that if
+# the file is over 4G, and the backing file path is stored after the first 4G,
+# the wrong filename will be printed. (This should be (8.Q), when that syntax
+# is introduced.)
+>>>(12.L)	 string >\0	(path %s)
+>>24	bequad	x	\b, %lld bytes
+>>32	belong	1	\b, AES-encrypted
+
+>4	belong	3	(v3)
+# Using the existence of the Backing File Offset to determine whether
+# to read Backing File Information
+>>8	bequad  >0	 \b, has backing file
+# Note that this isn't a null-terminated string; the length is actually
+# (16.L). Assuming a null-terminated string happens to work usually, but it
+# may spew junk until it reaches a \0 in some cases. Also, since there's no
+# .Q modifier, we just use the bottom four bytes as an offset. Note that if
+# the file is over 4G, and the backing file path is stored after the first 4G,
+# the wrong filename will be printed. (This should be (8.Q), when that syntax
+# is introduced.)
+>>>(12.L)	 string >\0	(path %s)
+>>24	bequad	x	\b, %lld bytes
+>>32	belong	1	\b, AES-encrypted
+
+>4	default x	(unknown version)
+
+0	string/b	QEVM		QEMU suspend to disk image
+
+# QEMU QED Image
+# http://wiki.qemu.org/Features/QED/Specification
+0	string/b	QED\0		QEMU QED Image
+
+# VDI Image
+# Sun xVM VirtualBox Disk Image
+# From: Richard W.M. Jones <rich@annexia.org>
+# VirtualBox Disk Image
+0x40	ulelong		0xbeda107f	VirtualBox Disk Image
+>0x44	uleshort	>0		\b, major %u
+>0x46	uleshort	>0		\b, minor %u
+>0	string		>\0		(%s)
+>368	lequad		x		 \b, %lld bytes
+
+0	string/b	Bochs\ Virtual\ HD\ Image	Bochs disk image,
+>32	string	x				type %s,
+>48	string	x				subtype %s
+
+0	lelong	0x02468ace			Bochs Sparse disk image
+

+ 6 - 6
magic/Magdir/vorbis

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: vorbis,v 1.16 2009/09/19 16:28:13 christos Exp $
+# $File: vorbis,v 1.18 2014/04/30 21:41:02 christos Exp $
 # vorbis:  file(1) magic for Ogg/Vorbis files
 # vorbis:  file(1) magic for Ogg/Vorbis files
 #
 #
 # From Felix von Leitner <leitner@fefe.de>
 # From Felix von Leitner <leitner@fefe.de>
@@ -56,13 +56,13 @@
 >>>37		string/c	xvid		(XviD)
 >>>37		string/c	xvid		(XviD)
 # --- First vorbis packet - general header ---
 # --- First vorbis packet - general header ---
 >>28		string		\x01vorbis	\b, Vorbis audio,
 >>28		string		\x01vorbis	\b, Vorbis audio,
->>>35		lelong		!0		UNKNOWN VERSION %lu,
+>>>35		lelong		!0		UNKNOWN VERSION %u,
 ##>>>35		lelong		0		version 0,
 ##>>>35		lelong		0		version 0,
 >>>35		lelong		0
 >>>35		lelong		0
 >>>>39		ubyte		1		mono,
 >>>>39		ubyte		1		mono,
 >>>>39		ubyte		2		stereo,
 >>>>39		ubyte		2		stereo,
 >>>>39		ubyte		>2		%u channels,
 >>>>39		ubyte		>2		%u channels,
->>>>40		lelong		x		%lu Hz
+>>>>40		lelong		x		%u Hz
 # Minimal, nominal and maximal bitrates specified when encoding
 # Minimal, nominal and maximal bitrates specified when encoding
 >>>>48		string		<\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff	\b,
 >>>>48		string		<\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff	\b,
 # The above tests if at least one of these is specified:
 # The above tests if at least one of these is specified:
@@ -72,13 +72,13 @@
 # Vorbis 1.0 uses 0 instead of -1.
 # Vorbis 1.0 uses 0 instead of -1.
 >>>>>>52	lelong		!0
 >>>>>>52	lelong		!0
 >>>>>>>52	lelong		!-1000
 >>>>>>>52	lelong		!-1000
->>>>>>>>52	lelong		x		<%lu
+>>>>>>>>52	lelong		x		<%u
 >>>>>48		lelong		!-1
 >>>>>48		lelong		!-1
->>>>>>48	lelong		x		~%lu
+>>>>>>48	lelong		x		~%u
 >>>>>44		lelong		!-1
 >>>>>44		lelong		!-1
 >>>>>>44	lelong		!-1000
 >>>>>>44	lelong		!-1000
 >>>>>>>44	lelong		!0
 >>>>>>>44	lelong		!0
->>>>>>>>44	lelong		x		>%lu
+>>>>>>>>44	lelong		x		>%u
 >>>>>48		string		<\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff	bps
 >>>>>48		string		<\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff	bps
 # -- Second vorbis header packet - the comments
 # -- Second vorbis header packet - the comments
 # A kludge to read the vendor string.  It's a counted string, not a
 # A kludge to read the vendor string.  It's a counted string, not a

+ 2 - 2
magic/Magdir/windows

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: windows,v 1.6 2013/04/19 20:12:29 christos Exp $
+# $File: windows,v 1.8 2014/04/30 21:41:02 christos Exp $
 # windows:  file(1) magic for Microsoft Windows
 # windows:  file(1) magic for Microsoft Windows
 #
 #
 # This file is mainly reserved for files where programs
 # This file is mainly reserved for files where programs
@@ -36,7 +36,7 @@
 >>0xf88	lelong		1		\b, full dump
 >>0xf88	lelong		1		\b, full dump
 >>0xf88	lelong		2		\b, kernel dump
 >>0xf88	lelong		2		\b, kernel dump
 >>0xf88	lelong		3		\b, small dump
 >>0xf88	lelong		3		\b, small dump
->>0x068	lelong		x		\b, %ld pages
+>>0x068	lelong		x		\b, %d pages
 >4	string		DU64		MS Windows 64bit crash dump
 >4	string		DU64		MS Windows 64bit crash dump
 >>0xf98	lelong		1		\b, full dump
 >>0xf98	lelong		1		\b, full dump
 >>0xf98	lelong		2		\b, kernel dump
 >>0xf98	lelong		2		\b, kernel dump

+ 2 - 2
magic/Magdir/xilinx

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: xilinx,v 1.6 2013/11/19 23:15:13 christos Exp $
+# $File: xilinx,v 1.7 2014/04/30 21:41:02 christos Exp $
 # This is Aaron's attempt at a MAGIC file for Xilinx .bit files.
 # This is Aaron's attempt at a MAGIC file for Xilinx .bit files.
 # Xilinx-Magic@RevRagnarok.com
 # Xilinx-Magic@RevRagnarok.com
 # Got the info from FPGA-FAQ 0026
 # Got the info from FPGA-FAQ 0026
@@ -33,7 +33,7 @@
 # Then 'e'
 # Then 'e'
 >>>>>>>>>>>&1  string e
 >>>>>>>>>>>&1  string e
 # And length of data
 # And length of data
->>>>>>>>>>>>&0 belong x          - data length 0x%lx
+>>>>>>>>>>>>&0 belong x          - data length 0x%x
 
 
 # Raw bitstream files
 # Raw bitstream files
 0      long    0xffffffff      
 0      long    0xffffffff      

+ 7 - 7
magic/Magdir/xwindows

@@ -1,6 +1,6 @@
 
 
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
-# $File: xwindows,v 1.8 2013/02/08 17:25:57 christos Exp $
+# $File: xwindows,v 1.9 2014/04/30 21:41:02 christos Exp $
 # xwindows:  file(1) magic for various X/Window system file formats.
 # xwindows:  file(1) magic for various X/Window system file formats.
 
 
 # Compiled X Keymap 
 # Compiled X Keymap 
@@ -18,10 +18,10 @@
 
 
 # Jaleo XFS files
 # Jaleo XFS files
 0	long	395726				Jaleo XFS file
 0	long	395726				Jaleo XFS file
->4	long	x				- version %ld
->8	long	x				- [%ld -
->20	long	x				\b%ldx
->24	long	x				\b%ldx
+>4	long	x				- version %d
+>8	long	x				- [%d -
+>20	long	x				\b%dx
+>24	long	x				\b%dx
 >28	long	1008				\bYUV422]
 >28	long	1008				\bYUV422]
 >28	long	1000				\bRGB24]
 >28	long	1000				\bRGB24]
 
 
@@ -31,5 +31,5 @@
 # http://cgit.freedesktop.org/xorg/lib/libXcursor/tree/include/X11/Xcursor/Xcursor.h
 # http://cgit.freedesktop.org/xorg/lib/libXcursor/tree/include/X11/Xcursor/Xcursor.h
 0	string		Xcur		Xcursor data
 0	string		Xcur		Xcursor data
 !:mime	image/x-xcursor
 !:mime	image/x-xcursor
->10	leshort		x		version %hd
->>8	leshort		x		\b.%hd
+>10	leshort		x		version %d
+>>8	leshort		x		\b.%d

+ 4 - 4
magic/Magdir/zfs

@@ -37,14 +37,14 @@
 
 
 # Big-endian values
 # Big-endian values
 8	string	\000\000\000\002\365\272\313\254 ZFS shapshot (big-endian machine),
 8	string	\000\000\000\002\365\272\313\254 ZFS shapshot (big-endian machine),
->20	belong	x	version %lu,
+>20	belong	x	version %u,
 >32	belong	0	type: NONE,
 >32	belong	0	type: NONE,
 >32	belong	1	type: META,
 >32	belong	1	type: META,
 >32	belong	2	type: ZFS,
 >32	belong	2	type: ZFS,
 >32	belong	3	type: ZVOL,
 >32	belong	3	type: ZVOL,
 >32	belong	4	type: OTHER,
 >32	belong	4	type: OTHER,
 >32	belong	5	type: ANY,
 >32	belong	5	type: ANY,
->32	belong	>5	type: UNKNOWN (%lu),
+>32	belong	>5	type: UNKNOWN (%u),
 >40	byte	x	destination GUID: %02X
 >40	byte	x	destination GUID: %02X
 >41	byte	x	%02X
 >41	byte	x	%02X
 >42	byte	x	%02X
 >42	byte	x	%02X
@@ -67,14 +67,14 @@
 
 
 # Little-endian values
 # Little-endian values
 8	string	\254\313\272\365\002\000\000\000	ZFS shapshot (little-endian machine),
 8	string	\254\313\272\365\002\000\000\000	ZFS shapshot (little-endian machine),
->16	lelong	x	version %lu,
+>16	lelong	x	version %u,
 >32	lelong	0	type: NONE,
 >32	lelong	0	type: NONE,
 >32	lelong	1	type: META,
 >32	lelong	1	type: META,
 >32	lelong	2	type: ZFS,
 >32	lelong	2	type: ZFS,
 >32	lelong	3	type: ZVOL,
 >32	lelong	3	type: ZVOL,
 >32	lelong	4	type: OTHER,
 >32	lelong	4	type: OTHER,
 >32	lelong	5	type: ANY,
 >32	lelong	5	type: ANY,
->32	lelong	>5	type: UNKNOWN (%lu),
+>32	lelong	>5	type: UNKNOWN (%u),
 >47	byte	x	destination GUID: %02X
 >47	byte	x	destination GUID: %02X
 >46	byte	x	%02X
 >46	byte	x	%02X
 >45	byte	x	%02X
 >45	byte	x	%02X

+ 3 - 1
magic/Makefile.am

@@ -1,5 +1,5 @@
 #
 #
-# $File: Makefile.am,v 1.96 2014/03/07 17:25:17 christos Exp $
+# $File: Makefile.am,v 1.98 2014/06/03 18:22:34 christos Exp $
 #
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
 MAGIC_DIR = $(top_srcdir)/magic
@@ -133,6 +133,7 @@ $(MAGIC_FRAGMENT_DIR)/macintosh \
 $(MAGIC_FRAGMENT_DIR)/magic \
 $(MAGIC_FRAGMENT_DIR)/magic \
 $(MAGIC_FRAGMENT_DIR)/mail.news \
 $(MAGIC_FRAGMENT_DIR)/mail.news \
 $(MAGIC_FRAGMENT_DIR)/make \
 $(MAGIC_FRAGMENT_DIR)/make \
+$(MAGIC_FRAGMENT_DIR)/map \
 $(MAGIC_FRAGMENT_DIR)/maple \
 $(MAGIC_FRAGMENT_DIR)/maple \
 $(MAGIC_FRAGMENT_DIR)/marc21 \
 $(MAGIC_FRAGMENT_DIR)/marc21 \
 $(MAGIC_FRAGMENT_DIR)/mathcad \
 $(MAGIC_FRAGMENT_DIR)/mathcad \
@@ -208,6 +209,7 @@ $(MAGIC_FRAGMENT_DIR)/securitycerts \
 $(MAGIC_FRAGMENT_DIR)/selinux \
 $(MAGIC_FRAGMENT_DIR)/selinux \
 $(MAGIC_FRAGMENT_DIR)/sendmail \
 $(MAGIC_FRAGMENT_DIR)/sendmail \
 $(MAGIC_FRAGMENT_DIR)/sequent \
 $(MAGIC_FRAGMENT_DIR)/sequent \
+$(MAGIC_FRAGMENT_DIR)/sereal \
 $(MAGIC_FRAGMENT_DIR)/sgi \
 $(MAGIC_FRAGMENT_DIR)/sgi \
 $(MAGIC_FRAGMENT_DIR)/sgml \
 $(MAGIC_FRAGMENT_DIR)/sgml \
 $(MAGIC_FRAGMENT_DIR)/sharc \
 $(MAGIC_FRAGMENT_DIR)/sharc \

+ 3 - 1
magic/Makefile.in

@@ -262,7 +262,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 top_srcdir = @top_srcdir@
 
 
 #
 #
-# $File: Makefile.am,v 1.96 2014/03/07 17:25:17 christos Exp $
+# $File: Makefile.am,v 1.98 2014/06/03 18:22:34 christos Exp $
 #
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
 MAGIC_DIR = $(top_srcdir)/magic
@@ -394,6 +394,7 @@ $(MAGIC_FRAGMENT_DIR)/macintosh \
 $(MAGIC_FRAGMENT_DIR)/magic \
 $(MAGIC_FRAGMENT_DIR)/magic \
 $(MAGIC_FRAGMENT_DIR)/mail.news \
 $(MAGIC_FRAGMENT_DIR)/mail.news \
 $(MAGIC_FRAGMENT_DIR)/make \
 $(MAGIC_FRAGMENT_DIR)/make \
+$(MAGIC_FRAGMENT_DIR)/map \
 $(MAGIC_FRAGMENT_DIR)/maple \
 $(MAGIC_FRAGMENT_DIR)/maple \
 $(MAGIC_FRAGMENT_DIR)/marc21 \
 $(MAGIC_FRAGMENT_DIR)/marc21 \
 $(MAGIC_FRAGMENT_DIR)/mathcad \
 $(MAGIC_FRAGMENT_DIR)/mathcad \
@@ -469,6 +470,7 @@ $(MAGIC_FRAGMENT_DIR)/securitycerts \
 $(MAGIC_FRAGMENT_DIR)/selinux \
 $(MAGIC_FRAGMENT_DIR)/selinux \
 $(MAGIC_FRAGMENT_DIR)/sendmail \
 $(MAGIC_FRAGMENT_DIR)/sendmail \
 $(MAGIC_FRAGMENT_DIR)/sequent \
 $(MAGIC_FRAGMENT_DIR)/sequent \
+$(MAGIC_FRAGMENT_DIR)/sereal \
 $(MAGIC_FRAGMENT_DIR)/sgi \
 $(MAGIC_FRAGMENT_DIR)/sgi \
 $(MAGIC_FRAGMENT_DIR)/sgml \
 $(MAGIC_FRAGMENT_DIR)/sgml \
 $(MAGIC_FRAGMENT_DIR)/sharc \
 $(MAGIC_FRAGMENT_DIR)/sharc \

+ 21 - 14
python/magic.py

@@ -8,10 +8,11 @@ import ctypes
 from ctypes import *
 from ctypes import *
 from ctypes.util import find_library
 from ctypes.util import find_library
 
 
+
 def _init():
 def _init():
     """
     """
     Loads the shared library through ctypes and returns a library
     Loads the shared library through ctypes and returns a library
-    L{ctypes.CDLL} instance 
+    L{ctypes.CDLL} instance
     """
     """
     return ctypes.cdll.LoadLibrary(find_library('magic'))
     return ctypes.cdll.LoadLibrary(find_library('magic'))
 
 
@@ -46,6 +47,7 @@ MAGIC_NO_CHECK_ENCODING = NO_CHECK_ENCODING = 2097152
 
 
 MAGIC_NO_CHECK_BUILTIN = NO_CHECK_BUILTIN = 4173824
 MAGIC_NO_CHECK_BUILTIN = NO_CHECK_BUILTIN = 4173824
 
 
+
 class magic_set(Structure):
 class magic_set(Structure):
     pass
     pass
 magic_set._fields_ = []
 magic_set._fields_ = []
@@ -99,6 +101,7 @@ _errno = _libraries['magic'].magic_errno
 _errno.restype = c_int
 _errno.restype = c_int
 _errno.argtypes = [magic_t]
 _errno.argtypes = [magic_t]
 
 
+
 class Magic(object):
 class Magic(object):
     def __init__(self, ms):
     def __init__(self, ms):
         self._magic_t = ms
         self._magic_t = ms
@@ -115,8 +118,11 @@ class Magic(object):
         as a filename or None if an error occurred and the MAGIC_ERROR flag
         as a filename or None if an error occurred and the MAGIC_ERROR flag
         is set.  A call to errno() will return the numeric error code.
         is set.  A call to errno() will return the numeric error code.
         """
         """
-        try: # attempt python3 approach first
-            bi = bytes(filename, 'utf-8')
+        try:  # attempt python3 approach first
+            if isinstance(filename, bytes):
+                bi = filename
+            else:
+                bi = bytes(filename, 'utf-8')
             return str(_file(self._magic_t, bi), 'utf-8')
             return str(_file(self._magic_t, bi), 'utf-8')
         except:
         except:
             return _file(self._magic_t, filename.encode('utf-8'))
             return _file(self._magic_t, filename.encode('utf-8'))
@@ -133,7 +139,7 @@ class Magic(object):
         as a buffer or None if an error occurred and the MAGIC_ERROR flag
         as a buffer or None if an error occurred and the MAGIC_ERROR flag
         is set. A call to errno() will return the numeric error code.
         is set. A call to errno() will return the numeric error code.
         """
         """
-        try: # attempt python3 approach first
+        try:  # attempt python3 approach first
             return str(_buffer(self._magic_t, buf, len(buf)), 'utf-8')
             return str(_buffer(self._magic_t, buf, len(buf)), 'utf-8')
         except:
         except:
             return _buffer(self._magic_t, buf, len(buf))
             return _buffer(self._magic_t, buf, len(buf))
@@ -143,16 +149,16 @@ class Magic(object):
         Returns a textual explanation of the last error or None
         Returns a textual explanation of the last error or None
         if there was no error.
         if there was no error.
         """
         """
-        try: # attempt python3 approach first
+        try:  # attempt python3 approach first
             return str(_error(self._magic_t), 'utf-8')
             return str(_error(self._magic_t), 'utf-8')
         except:
         except:
             return _error(self._magic_t)
             return _error(self._magic_t)
-  
+
     def setflags(self, flags):
     def setflags(self, flags):
         """
         """
-        Set flags on the magic object which determine how magic checking behaves;
-        a bitwise OR of the flags described in libmagic(3), but without the MAGIC_
-        prefix.
+        Set flags on the magic object which determine how magic checking
+        behaves; a bitwise OR of the flags described in libmagic(3), but
+        without the MAGIC_ prefix.
 
 
         Returns -1 on systems that don't support utime(2) or utimes(2)
         Returns -1 on systems that don't support utime(2) or utimes(2)
         when PRESERVE_ATIME is set.
         when PRESERVE_ATIME is set.
@@ -161,10 +167,10 @@ class Magic(object):
 
 
     def load(self, filename=None):
     def load(self, filename=None):
         """
         """
-        Must be called to load entries in the colon separated list of database files
-        passed as argument or the default database file if no argument before
-        any magic queries can be performed.
-        
+        Must be called to load entries in the colon separated list of database
+        files passed as argument or the default database file if no argument
+        before any magic queries can be performed.
+
         Returns 0 on success and -1 on failure.
         Returns 0 on success and -1 on failure.
         """
         """
         return _load(self._magic_t, filename)
         return _load(self._magic_t, filename)
@@ -196,7 +202,7 @@ class Magic(object):
         Returns 0 on success and -1 on failure.
         Returns 0 on success and -1 on failure.
         """
         """
         return _list(self._magic_t, dbs)
         return _list(self._magic_t, dbs)
-    
+
     def errno(self):
     def errno(self):
         """
         """
         Returns a numeric error code. If return value is 0, an internal
         Returns a numeric error code. If return value is 0, an internal
@@ -206,6 +212,7 @@ class Magic(object):
         """
         """
         return _errno(self._magic_t)
         return _errno(self._magic_t)
 
 
+
 def open(flags):
 def open(flags):
     """
     """
     Returns a magic object on success and None on failure.
     Returns a magic object on success and None on failure.

+ 3 - 3
src/Makefile.in

@@ -81,9 +81,9 @@ build_triplet = @build@
 host_triplet = @host@
 host_triplet = @host@
 bin_PROGRAMS = file$(EXEEXT)
 bin_PROGRAMS = file$(EXEEXT)
 subdir = src
 subdir = src
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ctime_r.c \
-	vasprintf.c pread.c strlcpy.c fmtcheck.c asctime_r.c \
-	strcasestr.c strlcat.c getopt_long.c asprintf.c getline.c \
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am pread.c \
+	ctime_r.c getline.c vasprintf.c asprintf.c asctime_r.c \
+	fmtcheck.c strlcpy.c getopt_long.c strcasestr.c strlcat.c \
 	$(top_srcdir)/depcomp $(include_HEADERS)
 	$(top_srcdir)/depcomp $(include_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \

+ 92 - 41
src/apprentice.c

@@ -32,7 +32,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.202 2014/03/14 18:48:11 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.211 2014/06/03 19:01:34 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -517,14 +517,18 @@ apprentice_unmap(struct magic_map *map)
 {
 {
 	if (map == NULL)
 	if (map == NULL)
 		return;
 		return;
-	if (map->p == NULL)
-		return;
+	if (map->p != NULL) {
 #ifdef QUICK
 #ifdef QUICK
-	if (map->len)
-		(void)munmap(map->p, map->len);
-	else
+		if (map->len)
+			(void)munmap(map->p, map->len);
+		else
 #endif
 #endif
 		free(map->p);
 		free(map->p);
+	} else {
+		uint32_t j;
+		for (j = 0; j < MAGIC_SETS; j++)
+			free(map->magic[j]);
+	}
 	free(map);
 	free(map);
 }
 }
 
 
@@ -779,7 +783,6 @@ apprentice_magic_strength(const struct magic *m)
 		break;
 		break;
 
 
 	default:
 	default:
-		val = 0;
 		(void)fprintf(stderr, "Bad type %d\n", m->type);
 		(void)fprintf(stderr, "Bad type %d\n", m->type);
 		abort();
 		abort();
 	}
 	}
@@ -1290,11 +1293,7 @@ out:
 		magic_entry_free(mset[j].me, mset[j].count);
 		magic_entry_free(mset[j].me, mset[j].count);
 
 
 	if (errs) {
 	if (errs) {
-		for (j = 0; j < MAGIC_SETS; j++) {
-			if (map->magic[j])
-				free(map->magic[j]);
-		}
-		free(map);
+		apprentice_unmap(map);
 		return NULL;
 		return NULL;
 	}
 	}
 	return map;
 	return map;
@@ -1383,7 +1382,8 @@ string_modifier_check(struct magic_set *ms, struct magic *m)
 	if ((ms->flags & MAGIC_CHECK) == 0)
 	if ((ms->flags & MAGIC_CHECK) == 0)
 		return 0;
 		return 0;
 
 
-	if (m->type != FILE_PSTRING && (m->str_flags & PSTRING_LEN) != 0) {
+	if ((m->type != FILE_REGEX || (m->str_flags & REGEX_LINE_COUNT) == 0) &&
+	    (m->type != FILE_PSTRING && (m->str_flags & PSTRING_LEN) != 0)) {
 		file_magwarn(ms,
 		file_magwarn(ms,
 		    "'/BHhLl' modifiers are only allowed for pascal strings\n");
 		    "'/BHhLl' modifiers are only allowed for pascal strings\n");
 		return -1;
 		return -1;
@@ -1749,7 +1749,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
 			 */
 			 */
 			m->type = get_standard_integer_type(l, &l);
 			m->type = get_standard_integer_type(l, &l);
 		}
 		}
-		// It's unsigned.
+		/* It's unsigned. */
 		if (m->type != FILE_INVALID)
 		if (m->type != FILE_INVALID)
 			m->flag |= UNSIGNED;
 			m->flag |= UNSIGNED;
 	} else {
 	} else {
@@ -1876,8 +1876,13 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
 					m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_BE;
 					m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_BE;
 					break;
 					break;
 				case CHAR_PSTRING_4_LE:
 				case CHAR_PSTRING_4_LE:
-					if (m->type != FILE_PSTRING)
+					switch (m->type) {
+					case FILE_PSTRING:
+					case FILE_REGEX:
+						break;
+					default:
 						goto bad;
 						goto bad;
+					}
 					m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_LE;
 					m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_LE;
 					break;
 					break;
 				case CHAR_PSTRING_LENGTH_INCLUDES_ITSELF:
 				case CHAR_PSTRING_LENGTH_INCLUDES_ITSELF:
@@ -2133,17 +2138,41 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line)
 private int
 private int
 check_format_type(const char *ptr, int type)
 check_format_type(const char *ptr, int type)
 {
 {
-	int quad = 0;
+	int quad = 0, h;
 	if (*ptr == '\0') {
 	if (*ptr == '\0') {
 		/* Missing format string; bad */
 		/* Missing format string; bad */
 		return -1;
 		return -1;
 	}
 	}
 
 
-	switch (type) {
+	switch (file_formats[type]) {
 	case FILE_FMT_QUAD:
 	case FILE_FMT_QUAD:
 		quad = 1;
 		quad = 1;
 		/*FALLTHROUGH*/
 		/*FALLTHROUGH*/
 	case FILE_FMT_NUM:
 	case FILE_FMT_NUM:
+		if (quad == 0) {
+			switch (type) {
+			case FILE_BYTE:
+				h = 2;
+				break;
+			case FILE_SHORT:
+			case FILE_BESHORT:
+			case FILE_LESHORT:
+				h = 1;
+				break;
+			case FILE_LONG:
+			case FILE_BELONG:
+			case FILE_LELONG:
+			case FILE_MELONG:
+			case FILE_LEID3:
+			case FILE_BEID3:
+			case FILE_INDIRECT:
+				h = 0;
+				break;
+			default:
+				abort();
+			}
+		} else
+			h = 0;
 		if (*ptr == '-')
 		if (*ptr == '-')
 			ptr++;
 			ptr++;
 		if (*ptr == '.')
 		if (*ptr == '.')
@@ -2160,6 +2189,8 @@ check_format_type(const char *ptr, int type)
 		}
 		}
 	
 	
 		switch (*ptr++) {
 		switch (*ptr++) {
+#ifdef STRICT_FORMAT 	/* "long" formats are int formats for us */
+		/* so don't accept the 'l' modifier */
 		case 'l':
 		case 'l':
 			switch (*ptr++) {
 			switch (*ptr++) {
 			case 'i':
 			case 'i':
@@ -2168,14 +2199,22 @@ check_format_type(const char *ptr, int type)
 			case 'o':
 			case 'o':
 			case 'x':
 			case 'x':
 			case 'X':
 			case 'X':
-				return 0;
+				return h != 0 ? -1 : 0;
 			default:
 			default:
 				return -1;
 				return -1;
 			}
 			}
 		
 		
+		/*
+		 * Don't accept h and hh modifiers. They make writing
+		 * magic entries more complicated, for very little benefit
+		 */
 		case 'h':
 		case 'h':
+			if (h-- <= 0)
+				return -1;
 			switch (*ptr++) {
 			switch (*ptr++) {
 			case 'h':
 			case 'h':
+				if (h-- <= 0)
+					return -1;
 				switch (*ptr++) {
 				switch (*ptr++) {
 				case 'i':
 				case 'i':
 				case 'd':
 				case 'd':
@@ -2187,21 +2226,30 @@ check_format_type(const char *ptr, int type)
 				default:
 				default:
 					return -1;
 					return -1;
 				}
 				}
+			case 'i':
 			case 'd':
 			case 'd':
-				return 0;
+			case 'u':
+			case 'o':
+			case 'x':
+			case 'X':
+				return h != 0 ? -1 : 0;
 			default:
 			default:
 				return -1;
 				return -1;
 			}
 			}
-
-		case 'i':
+#endif
 		case 'c':
 		case 'c':
+			return h != 2 ? -1 : 0;
+		case 'i':
 		case 'd':
 		case 'd':
 		case 'u':
 		case 'u':
 		case 'o':
 		case 'o':
 		case 'x':
 		case 'x':
 		case 'X':
 		case 'X':
+#ifdef STRICT_FORMAT
+			return h != 0 ? -1 : 0;
+#else
 			return 0;
 			return 0;
-			
+#endif
 		default:
 		default:
 			return -1;
 			return -1;
 		}
 		}
@@ -2288,7 +2336,7 @@ check_format(struct magic_set *ms, struct magic *m)
 	}
 	}
 
 
 	ptr++;
 	ptr++;
-	if (check_format_type(ptr, file_formats[m->type]) == -1) {
+	if (check_format_type(ptr, m->type) == -1) {
 		/*
 		/*
 		 * TODO: this error message is unhelpful if the format
 		 * TODO: this error message is unhelpful if the format
 		 * string is not one character long
 		 * string is not one character long
@@ -2335,6 +2383,16 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
 				    m->value.s);
 				    m->value.s);
 			return -1;
 			return -1;
 		}
 		}
+		if (m->type == FILE_REGEX) {
+			file_regex_t rx;
+			int rc = file_regcomp(&rx, m->value.s, REG_EXTENDED);
+			if (rc) {
+				if (ms->flags & MAGIC_CHECK)
+					file_regerror(&rx, rc, ms);
+			}
+			file_regfree(&rx);
+			return rc ? -1 : 0;
+		}
 		return 0;
 		return 0;
 	case FILE_FLOAT:
 	case FILE_FLOAT:
 	case FILE_BEFLOAT:
 	case FILE_BEFLOAT:
@@ -2715,7 +2773,8 @@ apprentice_map(struct magic_set *ms, const char *fn)
 	}
 	}
 	entries = (uint32_t)(st.st_size / sizeof(struct magic));
 	entries = (uint32_t)(st.st_size / sizeof(struct magic));
 	if ((off_t)(entries * sizeof(struct magic)) != st.st_size) {
 	if ((off_t)(entries * sizeof(struct magic)) != st.st_size) {
-		file_error(ms, 0, "Size of `%s' %llu is not a multiple of %zu",
+		file_error(ms, 0, "Size of `%s' %" INT64_T_FORMAT "u is not "
+		    "a multiple of %" SIZE_T_FORMAT "u",
 		    dbname, (unsigned long long)st.st_size,
 		    dbname, (unsigned long long)st.st_size,
 		    sizeof(struct magic));
 		    sizeof(struct magic));
 		goto error;
 		goto error;
@@ -2750,10 +2809,6 @@ error:
 	return NULL;
 	return NULL;
 }
 }
 
 
-private const uint32_t ar[] = {
-    MAGICNO, VERSIONNO
-};
-
 /*
 /*
  * handle an mmaped file.
  * handle an mmaped file.
  */
  */
@@ -2767,6 +2822,10 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn)
 	char *dbname;
 	char *dbname;
 	int rv = -1;
 	int rv = -1;
 	uint32_t i;
 	uint32_t i;
+	union {
+		struct magic m;
+		uint32_t h[2 + MAGIC_SETS];
+	} hdr;
 
 
 	dbname = mkdbname(ms, fn, 1);
 	dbname = mkdbname(ms, fn, 1);
 
 
@@ -2778,24 +2837,16 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn)
 		file_error(ms, errno, "cannot open `%s'", dbname);
 		file_error(ms, errno, "cannot open `%s'", dbname);
 		goto out;
 		goto out;
 	}
 	}
+	memset(&hdr, 0, sizeof(hdr));
+	hdr.h[0] = MAGICNO;
+	hdr.h[1] = VERSIONNO;
+	memcpy(hdr.h + 2, map->nmagic, nm);
 
 
-	if (write(fd, ar, sizeof(ar)) != (ssize_t)sizeof(ar)) {
+	if (write(fd, &hdr, sizeof(hdr)) != (ssize_t)sizeof(hdr)) {
 		file_error(ms, errno, "error writing `%s'", dbname);
 		file_error(ms, errno, "error writing `%s'", dbname);
 		goto out;
 		goto out;
 	}
 	}
 
 
-	if (write(fd, map->nmagic, nm) != (ssize_t)nm) {
-		file_error(ms, errno, "error writing `%s'", dbname);
-		goto out;
-	}
-
-	assert(nm + sizeof(ar) < m);
-
-	if (lseek(fd, (off_t)m, SEEK_SET) != (off_t)m) {
-		file_error(ms, errno, "error seeking `%s'", dbname);
-		goto out;
-	}
-
 	for (i = 0; i < MAGIC_SETS; i++) {
 	for (i = 0; i < MAGIC_SETS; i++) {
 		len = m * map->nmagic[i];
 		len = m * map->nmagic[i];
 		if (write(fd, map->magic[i], len) != (ssize_t)len) {
 		if (write(fd, map->magic[i], len) != (ssize_t)len) {

+ 45 - 26
src/cdf.c

@@ -35,7 +35,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef lint
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.55 2014/02/27 23:26:17 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.63 2014/06/09 13:04:37 christos Exp $")
 #endif
 #endif
 
 
 #include <assert.h>
 #include <assert.h>
@@ -267,13 +267,15 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
 {
 {
 	const char *b = (const char *)sst->sst_tab;
 	const char *b = (const char *)sst->sst_tab;
 	const char *e = ((const char *)p) + tail;
 	const char *e = ((const char *)p) + tail;
+	size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
+	    CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
 	(void)&line;
 	(void)&line;
-	if (e >= b && (size_t)(e - b) <= CDF_SEC_SIZE(h) * sst->sst_len)
+	if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
 		return 0;
 		return 0;
 	DPRINTF(("%d: offset begin %p < end %p || %" SIZE_T_FORMAT "u"
 	DPRINTF(("%d: offset begin %p < end %p || %" SIZE_T_FORMAT "u"
 	    " > %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
 	    " > %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
 	    SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
 	    SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
-	    CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
+	    ss * sst->sst_len, ss, sst->sst_len));
 	errno = EFTYPE;
 	errno = EFTYPE;
 	return -1;
 	return -1;
 }
 }
@@ -352,10 +354,10 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
 	size_t ss = CDF_SHORT_SEC_SIZE(h);
 	size_t ss = CDF_SHORT_SEC_SIZE(h);
 	size_t pos = CDF_SHORT_SEC_POS(h, id);
 	size_t pos = CDF_SHORT_SEC_POS(h, id);
 	assert(ss == len);
 	assert(ss == len);
-	if (pos > CDF_SEC_SIZE(h) * sst->sst_len) {
+	if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
 		DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
 		DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
 		    SIZE_T_FORMAT "u\n",
 		    SIZE_T_FORMAT "u\n",
-		    pos, CDF_SEC_SIZE(h) * sst->sst_len));
+		    pos + len, CDF_SEC_SIZE(h) * sst->sst_len));
 		return -1;
 		return -1;
 	}
 	}
 	(void)memcpy(((char *)buf) + offs,
 	(void)memcpy(((char *)buf) + offs,
@@ -455,7 +457,8 @@ size_t
 cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
 cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
 {
 {
 	size_t i, j;
 	size_t i, j;
-	cdf_secid_t maxsector = (cdf_secid_t)(sat->sat_len * size);
+	cdf_secid_t maxsector = (cdf_secid_t)((sat->sat_len * size)
+	    / sizeof(maxsector));
 
 
 	DPRINTF(("Chain:"));
 	DPRINTF(("Chain:"));
 	for (j = i = 0; sid >= 0; i++, j++) {
 	for (j = i = 0; sid >= 0; i++, j++) {
@@ -465,13 +468,18 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
 			errno = EFTYPE;
 			errno = EFTYPE;
 			return (size_t)-1;
 			return (size_t)-1;
 		}
 		}
-		if (sid > maxsector) {
-			DPRINTF(("Sector %d > %d\n", sid, maxsector));
+		if (sid >= maxsector) {
+			DPRINTF(("Sector %d >= %d\n", sid, maxsector));
 			errno = EFTYPE;
 			errno = EFTYPE;
 			return (size_t)-1;
 			return (size_t)-1;
 		}
 		}
 		sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
 		sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
 	}
 	}
+	if (i == 0) {
+		DPRINTF((" none, sid: %d\n", sid));
+		return (size_t)-1;
+
+	}
 	DPRINTF(("\n"));
 	DPRINTF(("\n"));
 	return i;
 	return i;
 }
 }
@@ -719,18 +727,27 @@ cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
     const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
     const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
     const cdf_dir_t *dir, cdf_stream_t *scn)
     const cdf_dir_t *dir, cdf_stream_t *scn)
 {
 {
+	return cdf_read_user_stream(info, h, sat, ssat, sst, dir,
+	    "\05SummaryInformation", scn);
+}
+
+int
+cdf_read_user_stream(const cdf_info_t *info, const cdf_header_t *h,
+    const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+    const cdf_dir_t *dir, const char *name, cdf_stream_t *scn)
+{
 	size_t i;
 	size_t i;
 	const cdf_directory_t *d;
 	const cdf_directory_t *d;
-	static const char name[] = "\05SummaryInformation";
+	size_t name_len = strlen(name) + 1;
 
 
 	for (i = dir->dir_len; i > 0; i--)
 	for (i = dir->dir_len; i > 0; i--)
 		if (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&
 		if (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&
-		    cdf_namecmp(name, dir->dir_tab[i - 1].d_name, sizeof(name))
+		    cdf_namecmp(name, dir->dir_tab[i - 1].d_name, name_len)
 		    == 0)
 		    == 0)
 			break;
 			break;
 
 
 	if (i == 0) {
 	if (i == 0) {
-		DPRINTF(("Cannot find summary information section\n"));
+		DPRINTF(("Cannot find user stream `%s'\n", name));
 		errno = ESRCH;
 		errno = ESRCH;
 		return -1;
 		return -1;
 	}
 	}
@@ -799,7 +816,11 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
 	if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
 	if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
 		goto out;
 		goto out;
 	for (i = 0; i < sh.sh_properties; i++) {
 	for (i = 0; i < sh.sh_properties; i++) {
-		size_t ofs = CDF_GETUINT32(p, (i << 1) + 1);
+		size_t tail = (i << 1) + 1;
+		if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t),
+		    __LINE__) == -1)
+			goto out;
+		size_t ofs = CDF_GETUINT32(p, tail);
 		q = (const uint8_t *)(const void *)
 		q = (const uint8_t *)(const void *)
 		    ((const char *)(const void *)p + ofs
 		    ((const char *)(const void *)p + ofs
 		    - 2 * sizeof(uint32_t));
 		    - 2 * sizeof(uint32_t));
@@ -813,6 +834,10 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
 		    i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
 		    i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
 		if (inp[i].pi_type & CDF_VECTOR) {
 		if (inp[i].pi_type & CDF_VECTOR) {
 			nelements = CDF_GETUINT32(q, 1);
 			nelements = CDF_GETUINT32(q, 1);
+			if (nelements == 0) {
+				DPRINTF(("CDF_VECTOR with nelements == 0\n"));
+				goto out;
+			}
 			o = 2;
 			o = 2;
 		} else {
 		} else {
 			nelements = 1;
 			nelements = 1;
@@ -887,7 +912,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
 			}
 			}
 			DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
 			DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
 			    nelements));
 			    nelements));
-			for (j = 0; j < nelements; j++, i++) {
+			for (j = 0; j < nelements && i < sh.sh_properties;
+			    j++, i++)
+			{
 				uint32_t l = CDF_GETUINT32(q, o);
 				uint32_t l = CDF_GETUINT32(q, o);
 				inp[i].pi_str.s_len = l;
 				inp[i].pi_str.s_len = l;
 				inp[i].pi_str.s_buf = (const char *)
 				inp[i].pi_str.s_buf = (const char *)
@@ -932,7 +959,7 @@ int
 cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
 cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
     cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
     cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
 {
 {
-	size_t i, maxcount;
+	size_t maxcount;
 	const cdf_summary_info_header_t *si =
 	const cdf_summary_info_header_t *si =
 	    CAST(const cdf_summary_info_header_t *, sst->sst_tab);
 	    CAST(const cdf_summary_info_header_t *, sst->sst_tab);
 	const cdf_section_declaration_t *sd =
 	const cdf_section_declaration_t *sd =
@@ -947,21 +974,13 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
 	ssi->si_os = CDF_TOLE2(si->si_os);
 	ssi->si_os = CDF_TOLE2(si->si_os);
 	ssi->si_class = si->si_class;
 	ssi->si_class = si->si_class;
 	cdf_swap_class(&ssi->si_class);
 	cdf_swap_class(&ssi->si_class);
-	ssi->si_count = CDF_TOLE2(si->si_count);
+	ssi->si_count = CDF_TOLE4(si->si_count);
 	*count = 0;
 	*count = 0;
 	maxcount = 0;
 	maxcount = 0;
 	*info = NULL;
 	*info = NULL;
-	for (i = 0; i < CDF_TOLE4(si->si_count); i++) {
-		if (i >= CDF_LOOP_LIMIT) {
-			DPRINTF(("Unpack summary info loop limit"));
-			errno = EFTYPE;
-			return -1;
-		}
-		if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset),
-		    info, count, &maxcount) == -1) {
-			return -1;
-		}
-	}
+	if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info,
+	    count, &maxcount) == -1)
+		return -1;
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 0
src/cdf.h

@@ -298,6 +298,9 @@ int cdf_read_short_stream(const cdf_info_t *, const cdf_header_t *,
     const cdf_directory_t **);
     const cdf_directory_t **);
 int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
 int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
     cdf_property_info_t **, size_t *, size_t *);
     cdf_property_info_t **, size_t *, size_t *);
+int cdf_read_user_stream(const cdf_info_t *, const cdf_header_t *,
+    const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
+    const cdf_dir_t *, const char *, cdf_stream_t *);
 int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
 int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
     const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
     const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
     const cdf_dir_t *, cdf_stream_t *);
     const cdf_dir_t *, cdf_stream_t *);

+ 4 - 3
src/cdf_time.c

@@ -27,7 +27,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef lint
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.13 2014/02/25 20:52:02 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.15 2014/05/14 23:15:42 christos Exp $")
 #endif
 #endif
 
 
 #include <time.h>
 #include <time.h>
@@ -117,7 +117,7 @@ cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
 	tm.tm_hour = (int)(t % 24);
 	tm.tm_hour = (int)(t % 24);
 	t /= 24;
 	t /= 24;
 
 
-	// XXX: Approx
+	/* XXX: Approx */
 	tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365));
 	tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365));
 
 
 	rdays = cdf_getdays(tm.tm_year);
 	rdays = cdf_getdays(tm.tm_year);
@@ -171,7 +171,8 @@ cdf_ctime(const time_t *sec, char *buf)
 	char *ptr = ctime_r(sec, buf);
 	char *ptr = ctime_r(sec, buf);
 	if (ptr != NULL)
 	if (ptr != NULL)
 		return buf;
 		return buf;
-	(void)snprintf(buf, 26, "*Bad* 0x%16.16llx\n", (long long)*sec);
+	(void)snprintf(buf, 26, "*Bad* 0x%16.16" INT64_T_FORMAT "x\n",
+	    (long long)*sec);
 	return buf;
 	return buf;
 }
 }
 
 

+ 16 - 3
src/file.h

@@ -27,7 +27,7 @@
  */
  */
 /*
 /*
  * file.h - definitions for file(1) program
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.149 2014/03/15 21:47:40 christos Exp $
+ * @(#)$File: file.h,v 1.152 2014/06/03 19:01:34 christos Exp $
  */
  */
 
 
 #ifndef __file_h__
 #ifndef __file_h__
@@ -83,7 +83,7 @@
 
 
 #define private static
 #define private static
 
 
-#if HAVE_VISIBILITY
+#if HAVE_VISIBILITY && !defined(WIN32)
 #define public  __attribute__ ((__visibility__("default")))
 #define public  __attribute__ ((__visibility__("default")))
 #ifndef protected
 #ifndef protected
 #define protected __attribute__ ((__visibility__("hidden")))
 #define protected __attribute__ ((__visibility__("hidden")))
@@ -133,7 +133,7 @@
 #define MAXstring 64		/* max len of "string" types */
 #define MAXstring 64		/* max len of "string" types */
 
 
 #define MAGICNO		0xF11E041C
 #define MAGICNO		0xF11E041C
-#define VERSIONNO	11
+#define VERSIONNO	12
 #define FILE_MAGICSIZE	248
 #define FILE_MAGICSIZE	248
 
 
 #define	FILE_LOAD	0
 #define	FILE_LOAD	0
@@ -321,6 +321,7 @@ struct magic {
 #define PSTRING_2_LE				BIT(9)
 #define PSTRING_2_LE				BIT(9)
 #define PSTRING_4_BE				BIT(10)
 #define PSTRING_4_BE				BIT(10)
 #define PSTRING_4_LE				BIT(11)
 #define PSTRING_4_LE				BIT(11)
+#define REGEX_LINE_COUNT			BIT(11)
 #define PSTRING_LEN	\
 #define PSTRING_LEN	\
     (PSTRING_1_BE|PSTRING_2_LE|PSTRING_2_BE|PSTRING_4_LE|PSTRING_4_BE)
     (PSTRING_1_BE|PSTRING_2_LE|PSTRING_2_BE|PSTRING_4_LE|PSTRING_4_BE)
 #define PSTRING_LENGTH_INCLUDES_ITSELF		BIT(12)
 #define PSTRING_LENGTH_INCLUDES_ITSELF		BIT(12)
@@ -468,6 +469,18 @@ protected int file_os2_apptype(struct magic_set *, const char *, const void *,
     size_t);
     size_t);
 #endif /* __EMX__ */
 #endif /* __EMX__ */
 
 
+typedef struct {
+	const char *pat;
+	char *old_lc_ctype;
+	int rc;
+	regex_t rx;
+} file_regex_t;
+
+protected int file_regcomp(file_regex_t *, const char *, int);
+protected int file_regexec(file_regex_t *, const char *, size_t, regmatch_t *,
+    int);
+protected void file_regfree(file_regex_t *);
+protected void file_regerror(file_regex_t *, int, struct magic_set *);
 
 
 #ifndef COMPILE_ONLY
 #ifndef COMPILE_ONLY
 extern const char *file_names[];
 extern const char *file_names[];

+ 37 - 4
src/fsmagic.c

@@ -32,7 +32,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.71 2013/12/01 18:01:07 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.73 2014/05/14 23:15:42 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -53,7 +53,11 @@ FILE_RCSID("@(#)$File: fsmagic.c,v 1.71 2013/12/01 18:01:07 christos Exp $")
 #ifdef major			/* Might be defined in sys/types.h.  */
 #ifdef major			/* Might be defined in sys/types.h.  */
 # define HAVE_MAJOR
 # define HAVE_MAJOR
 #endif
 #endif
-  
+#ifdef WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
 #ifndef HAVE_MAJOR
 #ifndef HAVE_MAJOR
 # define major(dev)  (((dev) >> 8) & 0xff)
 # define major(dev)  (((dev) >> 8) & 0xff)
 # define minor(dev)  ((dev) & 0xff)
 # define minor(dev)  ((dev) & 0xff)
@@ -123,6 +127,35 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 #endif
 #endif
 	ret = stat(fn, sb);	/* don't merge into if; see "ret =" above */
 	ret = stat(fn, sb);	/* don't merge into if; see "ret =" above */
 
 
+#ifdef WIN32
+	{
+		HANDLE hFile = CreateFile(fn, 0, FILE_SHARE_DELETE |
+		    FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0,
+		    NULL);
+		if (hFile != INVALID_HANDLE_VALUE) {
+			/*
+			 * Stat failed, but we can still open it - assume it's
+			 * a block device, if nothing else.
+			 */
+			if (ret) {
+				sb->st_mode = S_IFBLK;
+				ret = 0;
+			}
+			switch (GetFileType(hFile)) {
+			case FILE_TYPE_CHAR:
+				sb->st_mode |= S_IFCHR;
+				sb->st_mode &= ~S_IFREG;
+				break;
+			case FILE_TYPE_PIPE:
+				sb->st_mode |= S_IFIFO;
+				sb->st_mode &= ~S_IFREG;
+				break;
+			}
+			CloseHandle(hFile);
+		}
+	}
+#endif
+
 	if (ret) {
 	if (ret) {
 		if (ms->flags & MAGIC_ERROR) {
 		if (ms->flags & MAGIC_ERROR) {
 			file_error(ms, errno, "cannot stat `%s'", fn);
 			file_error(ms, errno, "cannot stat `%s'", fn);
@@ -176,7 +209,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 			if (handle_mime(ms, mime, "chardevice") == -1)
 			if (handle_mime(ms, mime, "chardevice") == -1)
 				return -1;
 				return -1;
 		} else {
 		} else {
-#ifdef HAVE_STAT_ST_RDEV
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
 # ifdef dv_unit
 # ifdef dv_unit
 			if (file_printf(ms, "%scharacter special (%d/%d/%d)",
 			if (file_printf(ms, "%scharacter special (%d/%d/%d)",
 			    COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
 			    COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
@@ -210,7 +243,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 			if (handle_mime(ms, mime, "blockdevice") == -1)
 			if (handle_mime(ms, mime, "blockdevice") == -1)
 				return -1;
 				return -1;
 		} else {
 		} else {
-#ifdef HAVE_STAT_ST_RDEV
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
 # ifdef dv_unit
 # ifdef dv_unit
 			if (file_printf(ms, "%sblock special (%d/%d/%d)",
 			if (file_printf(ms, "%sblock special (%d/%d/%d)",
 			    COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
 			    COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),

+ 48 - 16
src/funcs.c

@@ -27,7 +27,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.70 2014/03/14 19:02:37 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.72 2014/05/14 23:15:42 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -280,7 +280,9 @@ simple:
 		if (file_printf(ms, "%s", code_mime) == -1)
 		if (file_printf(ms, "%s", code_mime) == -1)
 			rv = -1;
 			rv = -1;
 	}
 	}
+#if HAVE_FORK
  done_encoding:
  done_encoding:
+#endif
 	free(u8buf);
 	free(u8buf);
 	if (rv)
 	if (rv)
 		return rv;
 		return rv;
@@ -427,35 +429,65 @@ file_printedlen(const struct magic_set *ms)
 protected int
 protected int
 file_replace(struct magic_set *ms, const char *pat, const char *rep)
 file_replace(struct magic_set *ms, const char *pat, const char *rep)
 {
 {
-	regex_t rx;
+	file_regex_t rx;
 	int rc, rv = -1;
 	int rc, rv = -1;
-	char *old_lc_ctype;
 
 
-	old_lc_ctype = setlocale(LC_CTYPE, NULL);
-	assert(old_lc_ctype != NULL);
-	old_lc_ctype = strdup(old_lc_ctype);
-	assert(old_lc_ctype != NULL);
-	(void)setlocale(LC_CTYPE, "C");
-	rc = regcomp(&rx, pat, REG_EXTENDED);
+	rc = file_regcomp(&rx, pat, REG_EXTENDED);
 	if (rc) {
 	if (rc) {
-		char errmsg[512];
-		(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
-		file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
+		file_regerror(&rx, rc, ms);
 	} else {
 	} else {
 		regmatch_t rm;
 		regmatch_t rm;
 		int nm = 0;
 		int nm = 0;
-		while (regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) {
+		while (file_regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) {
 			ms->o.buf[rm.rm_so] = '\0';
 			ms->o.buf[rm.rm_so] = '\0';
 			if (file_printf(ms, "%s%s", rep,
 			if (file_printf(ms, "%s%s", rep,
 			    rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1)
 			    rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1)
 				goto out;
 				goto out;
 			nm++;
 			nm++;
 		}
 		}
-		regfree(&rx);
 		rv = nm;
 		rv = nm;
 	}
 	}
 out:
 out:
-	(void)setlocale(LC_CTYPE, old_lc_ctype);
-	free(old_lc_ctype);
+	file_regfree(&rx);
 	return rv;
 	return rv;
 }
 }
+
+protected int
+file_regcomp(file_regex_t *rx, const char *pat, int flags)
+{
+	rx->old_lc_ctype = setlocale(LC_CTYPE, NULL);
+	assert(rx->old_lc_ctype != NULL);
+	rx->old_lc_ctype = strdup(rx->old_lc_ctype);
+	assert(rx->old_lc_ctype != NULL);
+	rx->pat = pat;
+
+	(void)setlocale(LC_CTYPE, "C");
+	return rx->rc = regcomp(&rx->rx, pat, flags);
+}
+
+protected int
+file_regexec(file_regex_t *rx, const char *str, size_t nmatch,
+    regmatch_t* pmatch, int eflags)
+{
+	assert(rx->rc == 0);
+	return regexec(&rx->rx, str, nmatch, pmatch, eflags);
+}
+
+protected void
+file_regfree(file_regex_t *rx)
+{
+	if (rx->rc == 0)
+		regfree(&rx->rx);
+	(void)setlocale(LC_CTYPE, rx->old_lc_ctype);
+	free(rx->old_lc_ctype);
+}
+
+protected void
+file_regerror(file_regex_t *rx, int rc, struct magic_set *ms)
+{
+	char errmsg[512];
+
+	(void)regerror(rc, &rx->rx, errmsg, sizeof(errmsg));
+	file_magerror(ms, "regex error %d for `%s', (%s)", rc, rx->pat,
+	    errmsg);
+}

+ 46 - 14
src/magic.c

@@ -33,7 +33,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: magic.c,v 1.81 2013/11/29 15:42:51 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.84 2014/05/14 23:15:42 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
@@ -126,8 +126,9 @@ out:
 	free(hmagicpath);
 	free(hmagicpath);
 	return MAGIC;
 	return MAGIC;
 #else
 #else
-	char *hmagicp = hmagicpath;
+	char *hmagicp;
 	char *tmppath = NULL;
 	char *tmppath = NULL;
+	hmagicpath = NULL;
 
 
 #define APPENDPATH() \
 #define APPENDPATH() \
 	do { \
 	do { \
@@ -220,13 +221,15 @@ magic_open(int flags)
 private int
 private int
 unreadable_info(struct magic_set *ms, mode_t md, const char *file)
 unreadable_info(struct magic_set *ms, mode_t md, const char *file)
 {
 {
-	/* We cannot open it, but we were able to stat it. */
-	if (access(file, W_OK) == 0)
-		if (file_printf(ms, "writable, ") == -1)
-			return -1;
-	if (access(file, X_OK) == 0)
-		if (file_printf(ms, "executable, ") == -1)
-			return -1;
+	if (file) {
+		/* We cannot open it, but we were able to stat it. */
+		if (access(file, W_OK) == 0)
+			if (file_printf(ms, "writable, ") == -1)
+				return -1;
+		if (access(file, X_OK) == 0)
+			if (file_printf(ms, "executable, ") == -1)
+				return -1;
+	}
 	if (S_ISREG(md))
 	if (S_ISREG(md))
 		if (file_printf(ms, "regular file, ") == -1)
 		if (file_printf(ms, "regular file, ") == -1)
 			return -1;
 			return -1;
@@ -345,6 +348,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 	int	ispipe = 0;
 	int	ispipe = 0;
 	off_t	pos = (off_t)-1;
 	off_t	pos = (off_t)-1;
 
 
+	if (file_reset(ms) == -1)
+		goto out;
+
 	/*
 	/*
 	 * one extra for terminating '\0', and
 	 * one extra for terminating '\0', and
 	 * some overlapping space for matches near EOF
 	 * some overlapping space for matches near EOF
@@ -353,9 +359,6 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 	if ((buf = CAST(unsigned char *, malloc(HOWMANY + SLOP))) == NULL)
 	if ((buf = CAST(unsigned char *, malloc(HOWMANY + SLOP))) == NULL)
 		return NULL;
 		return NULL;
 
 
-	if (file_reset(ms) == -1)
-		goto done;
-
 	switch (file_fsmagic(ms, inname, &sb)) {
 	switch (file_fsmagic(ms, inname, &sb)) {
 	case -1:		/* error */
 	case -1:		/* error */
 		goto done;
 		goto done;
@@ -366,6 +369,12 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 		goto done;
 		goto done;
 	}
 	}
 
 
+#ifdef WIN32
+	/* Place stdin in binary mode, so EOF (Ctrl+Z) doesn't stop early. */
+	if (fd == STDIN_FILENO)
+		_setmode(STDIN_FILENO, O_BINARY);
+#endif
+
 	if (inname == NULL) {
 	if (inname == NULL) {
 		if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode))
 		if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode))
 			ispipe = 1;
 			ispipe = 1;
@@ -384,6 +393,18 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 
 
 		errno = 0;
 		errno = 0;
 		if ((fd = open(inname, flags)) < 0) {
 		if ((fd = open(inname, flags)) < 0) {
+#ifdef WIN32
+			/*
+			 * Can't stat, can't open.  It may have been opened in
+			 * fsmagic, so if the user doesn't have read permission,
+			 * allow it to say so; otherwise an error was probably
+			 * displayed in fsmagic.
+			 */
+			if (!okstat && errno == EACCES) {
+				sb.st_mode = S_IFBLK;
+				okstat = 1;
+			}
+#endif
 			if (okstat &&
 			if (okstat &&
 			    unreadable_info(ms, sb.st_mode, inname) == -1)
 			    unreadable_info(ms, sb.st_mode, inname) == -1)
 				goto done;
 				goto done;
@@ -419,8 +440,18 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 		}
 		}
 
 
 	} else {
 	} else {
-		if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
-			file_error(ms, errno, "cannot read `%s'", inname);
+		/* Windows refuses to read from a big console buffer. */
+		size_t howmany =
+#if defined(WIN32) && HOWMANY > 8 * 1024
+				_isatty(fd) ? 8 * 1024 :
+#endif
+				HOWMANY;
+		if ((nbytes = read(fd, (char *)buf, howmany)) == -1) {
+			if (inname == NULL && fd != STDIN_FILENO)
+				file_error(ms, errno, "cannot read fd %d", fd);
+			else
+				file_error(ms, errno, "cannot read `%s'",
+				    inname == NULL ? "/dev/stdin" : inname);
 			goto done;
 			goto done;
 		}
 		}
 	}
 	}
@@ -434,6 +465,7 @@ done:
 	if (pos != (off_t)-1)
 	if (pos != (off_t)-1)
 		(void)lseek(fd, pos, SEEK_SET);
 		(void)lseek(fd, pos, SEEK_SET);
 	close_and_restore(ms, inname, fd, &sb);
 	close_and_restore(ms, inname, fd, &sb);
+out:
 	return rv == 0 ? file_getbuffer(ms) : NULL;
 	return rv == 0 ? file_getbuffer(ms) : NULL;
 }
 }
 
 

+ 1 - 1
src/magic.h

@@ -75,7 +75,7 @@
 #define	MAGIC_NO_CHECK_FORTRAN	0x000000 /* Don't check ascii/fortran */
 #define	MAGIC_NO_CHECK_FORTRAN	0x000000 /* Don't check ascii/fortran */
 #define	MAGIC_NO_CHECK_TROFF	0x000000 /* Don't check ascii/troff */
 #define	MAGIC_NO_CHECK_TROFF	0x000000 /* Don't check ascii/troff */
 
 
-#define MAGIC_VERSION		517	/* This implementation */
+#define MAGIC_VERSION		518	/* This implementation */
 
 
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus

+ 53 - 20
src/readcdf.c

@@ -26,7 +26,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef lint
 #ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.40 2014/03/06 15:23:33 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.44 2014/05/14 23:22:48 christos Exp $")
 #endif
 #endif
 
 
 #include <assert.h>
 #include <assert.h>
@@ -75,14 +75,20 @@ static const struct cv {
 	const char *mime;
 	const char *mime;
 } clsid2mime[] = {
 } clsid2mime[] = {
 	{
 	{
-		{ 0x00000000000c1084LLU, 0x46000000000000c0LLU },
+		{ 0x00000000000c1084LLU, 0x46000000000000c0LLU  },
 		"x-msi",
 		"x-msi",
-	}
+	},
+	{	{ 0,			 0			},
+		NULL,
+	},
 }, clsid2desc[] = {
 }, clsid2desc[] = {
 	{
 	{
-		{ 0x00000000000c1084LLU, 0x46000000000000c0LLU },
+		{ 0x00000000000c1084LLU, 0x46000000000000c0LLU  },
 		"MSI Installer",
 		"MSI Installer",
 	},
 	},
+	{	{ 0,			 0			},
+		NULL,
+	},
 };
 };
 
 
 private const char *
 private const char *
@@ -120,7 +126,7 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
 
 
 private int
 private int
 cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
 cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
-    size_t count, const uint64_t clsid[2])
+    size_t count, const cdf_directory_t *root_storage)
 {
 {
         size_t i;
         size_t i;
         cdf_timestamp_t tp;
         cdf_timestamp_t tp;
@@ -130,8 +136,9 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
         const char *s;
         const char *s;
         int len;
         int len;
 
 
-        if (!NOTMIME(ms))
-		str = cdf_clsid_to_mime(clsid, clsid2mime);
+        if (!NOTMIME(ms) && root_storage)
+		str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
+		    clsid2mime);
 
 
         for (i = 0; i < count; i++) {
         for (i = 0; i < count; i++) {
                 cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
                 cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
@@ -173,12 +180,11 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
                                 if (info[i].pi_type == CDF_LENGTH32_WSTRING)
                                 if (info[i].pi_type == CDF_LENGTH32_WSTRING)
                                     k++;
                                     k++;
                                 s = info[i].pi_str.s_buf;
                                 s = info[i].pi_str.s_buf;
-                                for (j = 0; j < sizeof(vbuf) && len--;
-                                    j++, s += k) {
+                                for (j = 0; j < sizeof(vbuf) && len--; s += k) {
                                         if (*s == '\0')
                                         if (*s == '\0')
                                                 break;
                                                 break;
                                         if (isprint((unsigned char)*s))
                                         if (isprint((unsigned char)*s))
-                                                vbuf[j] = *s;
+                                                vbuf[j++] = *s;
                                 }
                                 }
                                 if (j == sizeof(vbuf))
                                 if (j == sizeof(vbuf))
                                         --j;
                                         --j;
@@ -236,7 +242,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
 
 
 private int
 private int
 cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
 cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
-    const cdf_stream_t *sst, const uint64_t clsid[2])
+    const cdf_stream_t *sst, const cdf_directory_t *root_storage)
 {
 {
         cdf_summary_info_header_t si;
         cdf_summary_info_header_t si;
         cdf_property_info_t *info;
         cdf_property_info_t *info;
@@ -276,13 +282,16 @@ cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
                                 return -2;
                                 return -2;
                         break;
                         break;
                 }
                 }
-		str = cdf_clsid_to_mime(clsid, clsid2desc);
-		if (str)
-                        if (file_printf(ms, ", %s", str) == -1)
-				return -2;
-        }
+		if (root_storage) {
+			str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
+			    clsid2desc);
+			if (str)
+				if (file_printf(ms, ", %s", str) == -1)
+					return -2;
+			}
+		}
 
 
-        m = cdf_file_property_info(ms, info, count, clsid);
+        m = cdf_file_property_info(ms, info, count, root_storage);
         free(info);
         free(info);
 
 
         return m == -1 ? -2 : m;
         return m == -1 ? -2 : m;
@@ -368,6 +377,30 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
 	}
 	}
 #endif
 #endif
 
 
+	if ((i = cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, &dir,
+	    "FileHeader", &scn)) != -1) {
+#define HWP5_SIGNATURE "HWP Document File"
+		if (scn.sst_dirlen >= sizeof(HWP5_SIGNATURE) - 1
+		    && memcmp(scn.sst_tab, HWP5_SIGNATURE,
+		    sizeof(HWP5_SIGNATURE) - 1) == 0) {
+		    if (NOTMIME(ms)) {
+			if (file_printf(ms,
+			    "Hangul (Korean) Word Processor File 5.x") == -1)
+			    return -1;
+		    } else {
+			if (file_printf(ms, "application/x-hwp") == -1)
+			    return -1;
+		    }
+		    i = 1;
+		    goto out5;
+		} else {
+		    free(scn.sst_tab);
+		    scn.sst_tab = NULL;
+		    scn.sst_len = 0;
+		    scn.sst_dirlen = 0;
+		}
+	}
+
         if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
         if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
             &scn)) == -1) {
             &scn)) == -1) {
                 if (errno == ESRCH) {
                 if (errno == ESRCH) {
@@ -381,9 +414,8 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
 #ifdef CDF_DEBUG
 #ifdef CDF_DEBUG
         cdf_dump_summary_info(&h, &scn);
         cdf_dump_summary_info(&h, &scn);
 #endif
 #endif
-        if ((i = cdf_file_summary_info(ms, &h, &scn,
-	    root_storage->d_storage_uuid)) < 0)
-                expn = "Can't expand summary_info";
+        if ((i = cdf_file_summary_info(ms, &h, &scn, root_storage)) < 0)
+            expn = "Can't expand summary_info";
 
 
 	if (i == 0) {
 	if (i == 0) {
 		const char *str = NULL;
 		const char *str = NULL;
@@ -412,6 +444,7 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
 			i = 1;
 			i = 1;
 		}
 		}
 	}
 	}
+out5:
         free(scn.sst_tab);
         free(scn.sst_tab);
 out4:
 out4:
         free(sst.sst_tab);
         free(sst.sst_tab);

+ 31 - 1
src/readelf.c

@@ -27,7 +27,7 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef lint
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.102 2014/03/11 21:00:13 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.103 2014/05/02 02:25:10 christos Exp $")
 #endif
 #endif
 
 
 #ifdef BUILTIN_ELF
 #ifdef BUILTIN_ELF
@@ -1005,6 +1005,36 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
 					file_badread(ms);
 					file_badread(ms);
 					return -1;
 					return -1;
 				}
 				}
+				if (cbuf[0] == 'A') {
+#ifdef notyet
+					char *p = cbuf + 1;
+					uint32_t len, tag;
+					memcpy(&len, p, sizeof(len));
+					p += 4;
+					len = getu32(swap, len);
+					if (memcmp("gnu", p, 3) != 0) {
+					    if (file_printf(ms,
+						", unknown capability %.3s", p)
+						== -1)
+						return -1;
+					    break;
+					}
+					p += strlen(p) + 1;
+					tag = *p++;
+					memcpy(&len, p, sizeof(len));
+					p += 4;
+					len = getu32(swap, len);
+					if (tag != 1) {
+					    if (file_printf(ms, ", unknown gnu"
+						" capability tag %d", tag)
+						== -1)
+						return -1;
+					    break;
+					}
+					// gnu attributes 
+#endif
+					break;
+				}
 				(void)memcpy(xcap_addr, cbuf, xcap_sizeof);
 				(void)memcpy(xcap_addr, cbuf, xcap_sizeof);
 				switch (xcap_tag) {
 				switch (xcap_tag) {
 				case CA_SUNW_NULL:
 				case CA_SUNW_NULL:

+ 173 - 283
src/softmagic.c

@@ -32,11 +32,10 @@
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.180 2014/03/15 21:47:40 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.191 2014/06/04 17:36:34 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include "magic.h"
 #include "magic.h"
-#define F(a, b) fmtcheck((a), (b))
 #include <assert.h>
 #include <assert.h>
 #include <string.h>
 #include <string.h>
 #include <ctype.h>
 #include <ctype.h>
@@ -58,7 +57,7 @@ private int32_t mprint(struct magic_set *, struct magic *);
 private int32_t moffset(struct magic_set *, struct magic *);
 private int32_t moffset(struct magic_set *, struct magic *);
 private void mdebug(uint32_t, const char *, size_t);
 private void mdebug(uint32_t, const char *, size_t);
 private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
 private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
-    const unsigned char *, uint32_t, size_t, size_t);
+    const unsigned char *, uint32_t, size_t, struct magic *);
 private int mconvert(struct magic_set *, struct magic *, int);
 private int mconvert(struct magic_set *, struct magic *, int);
 private int print_sep(struct magic_set *, int);
 private int print_sep(struct magic_set *, int);
 private int handle_annotation(struct magic_set *, struct magic *);
 private int handle_annotation(struct magic_set *, struct magic *);
@@ -88,6 +87,25 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
 	return 0;
 	return 0;
 }
 }
 
 
+#define FILE_FMTDEBUG
+#ifdef FILE_FMTDEBUG
+#define F(a, b, c) file_fmtcheck((a), (b), (c), __FILE__, __LINE__)
+
+private const char * __attribute__((__format_arg__(3)))
+file_fmtcheck(struct magic_set *ms, const struct magic *m, const char *def,
+	const char *file, size_t line)
+{
+	const char *ptr = fmtcheck(m->desc, def);
+	if (ptr == def)
+		file_magerror(ms,
+		    "%s, %zu: format `%s' does not match with `%s'",
+		    file, line, m->desc, def);
+	return ptr;
+}
+#else
+#define F(a, b, c) fmtcheck((b)->desc, (c))
+#endif
+
 /*
 /*
  * Go through the whole list, stopping if you find a match.  Process all
  * Go through the whole list, stopping if you find a match.  Process all
  * the continuations of that match before returning.
  * the continuations of that match before returning.
@@ -217,8 +235,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 		if (file_check_mem(ms, ++cont_level) == -1)
 		if (file_check_mem(ms, ++cont_level) == -1)
 			return -1;
 			return -1;
 
 
-		while (magic[magindex+1].cont_level != 0 &&
-		    ++magindex < nmagic) {
+		while (++magindex < nmagic &&
+		    magic[magindex].cont_level != 0) {
 			m = &magic[magindex];
 			m = &magic[magindex];
 			ms->line = m->lineno; /* for messages */
 			ms->line = m->lineno; /* for messages */
 
 
@@ -346,30 +364,20 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 private int
 private int
 check_fmt(struct magic_set *ms, struct magic *m)
 check_fmt(struct magic_set *ms, struct magic *m)
 {
 {
-	regex_t rx;
+	file_regex_t rx;
 	int rc, rv = -1;
 	int rc, rv = -1;
-	char *old_lc_ctype;
 
 
 	if (strchr(m->desc, '%') == NULL)
 	if (strchr(m->desc, '%') == NULL)
 		return 0;
 		return 0;
 
 
-	old_lc_ctype = setlocale(LC_CTYPE, NULL);
-	assert(old_lc_ctype != NULL);
-	old_lc_ctype = strdup(old_lc_ctype);
-	assert(old_lc_ctype != NULL);
-	(void)setlocale(LC_CTYPE, "C");
-	rc = regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
+	rc = file_regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
 	if (rc) {
 	if (rc) {
-		char errmsg[512];
-		(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
-		file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
+		file_regerror(&rx, rc, ms);
 	} else {
 	} else {
-		rc = regexec(&rx, m->desc, 0, 0, 0);
-		regfree(&rx);
+		rc = file_regexec(&rx, m->desc, 0, 0, 0);
 		rv = !rc;
 		rv = !rc;
 	}
 	}
-	(void)setlocale(LC_CTYPE, old_lc_ctype);
-	free(old_lc_ctype);
+	file_regfree(&rx);
 	return rv;
 	return rv;
 }
 }
 
 
@@ -409,13 +417,13 @@ mprint(struct magic_set *ms, struct magic *m)
 		case -1:
 		case -1:
 			return -1;
 			return -1;
 		case 1:
 		case 1:
-			(void)snprintf(buf, sizeof(buf), "%c",
+			(void)snprintf(buf, sizeof(buf), "%d",
 			    (unsigned char)v);
 			    (unsigned char)v);
-			if (file_printf(ms, F(m->desc, "%s"), buf) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		default:
 		default:
-			if (file_printf(ms, F(m->desc, "%c"),
+			if (file_printf(ms, F(ms, m, "%d"),
 			    (unsigned char) v) == -1)
 			    (unsigned char) v) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
@@ -431,13 +439,13 @@ mprint(struct magic_set *ms, struct magic *m)
 		case -1:
 		case -1:
 			return -1;
 			return -1;
 		case 1:
 		case 1:
-			(void)snprintf(buf, sizeof(buf), "%hu",
+			(void)snprintf(buf, sizeof(buf), "%u",
 			    (unsigned short)v);
 			    (unsigned short)v);
-			if (file_printf(ms, F(m->desc, "%s"), buf) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		default:
 		default:
-			if (file_printf(ms, F(m->desc, "%hu"),
+			if (file_printf(ms, F(ms, m, "%u"),
 			    (unsigned short) v) == -1)
 			    (unsigned short) v) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
@@ -454,13 +462,12 @@ mprint(struct magic_set *ms, struct magic *m)
 		case -1:
 		case -1:
 			return -1;
 			return -1;
 		case 1:
 		case 1:
-			(void)snprintf(buf, sizeof(buf), "%u", (uint32_t)v);
-			if (file_printf(ms, F(m->desc, "%s"), buf) == -1)
+			(void)snprintf(buf, sizeof(buf), "%u", (uint32_t) v);
+			if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		default:
 		default:
-			if (file_printf(ms, F(m->desc, "%u"),
-			    (uint32_t) v) == -1)
+			if (file_printf(ms, F(ms, m, "%u"), (uint32_t) v) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		}
 		}
@@ -475,13 +482,13 @@ mprint(struct magic_set *ms, struct magic *m)
 		case -1:
 		case -1:
 			return -1;
 			return -1;
 		case 1:
 		case 1:
-			(void)snprintf(buf, sizeof(buf), "%llu",
+			(void)snprintf(buf, sizeof(buf), "%" INT64_T_FORMAT "u",
 			    (unsigned long long)v);
 			    (unsigned long long)v);
-			if (file_printf(ms, F(m->desc, "%s"), buf) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		default:
 		default:
-			if (file_printf(ms, F(m->desc, "%llu"),
+			if (file_printf(ms, F(ms, m, "%" INT64_T_FORMAT "u"),
 			    (unsigned long long) v) == -1)
 			    (unsigned long long) v) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
@@ -494,7 +501,7 @@ mprint(struct magic_set *ms, struct magic *m)
   	case FILE_BESTRING16:
   	case FILE_BESTRING16:
   	case FILE_LESTRING16:
   	case FILE_LESTRING16:
 		if (m->reln == '=' || m->reln == '!') {
 		if (m->reln == '=' || m->reln == '!') {
-			if (file_printf(ms, F(m->desc, "%s"), m->value.s) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), m->value.s) == -1)
 				return -1;
 				return -1;
 			t = ms->offset + m->vallen;
 			t = ms->offset + m->vallen;
 		}
 		}
@@ -520,7 +527,7 @@ mprint(struct magic_set *ms, struct magic *m)
 				*++last = '\0';
 				*++last = '\0';
 			}
 			}
 
 
-			if (file_printf(ms, F(m->desc, "%s"), str) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), str) == -1)
 				return -1;
 				return -1;
 
 
 			if (m->type == FILE_PSTRING)
 			if (m->type == FILE_PSTRING)
@@ -532,8 +539,8 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_BEDATE:
 	case FILE_BEDATE:
 	case FILE_LEDATE:
 	case FILE_LEDATE:
 	case FILE_MEDATE:
 	case FILE_MEDATE:
-		if (file_printf(ms, F(m->desc, "%s"),
-		    file_fmttime(p->l, FILE_T_LOCAL, tbuf)) == -1)
+		if (file_printf(ms, F(ms, m, "%s"),
+		    file_fmttime(p->l + m->num_mask, FILE_T_LOCAL, tbuf)) == -1)
 			return -1;
 			return -1;
 		t = ms->offset + sizeof(uint32_t);
 		t = ms->offset + sizeof(uint32_t);
 		break;
 		break;
@@ -542,8 +549,8 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_BELDATE:
 	case FILE_BELDATE:
 	case FILE_LELDATE:
 	case FILE_LELDATE:
 	case FILE_MELDATE:
 	case FILE_MELDATE:
-		if (file_printf(ms, F(m->desc, "%s"),
-		    file_fmttime(p->l, 0, tbuf)) == -1)
+		if (file_printf(ms, F(ms, m, "%s"),
+		    file_fmttime(p->l + m->num_mask, 0, tbuf)) == -1)
 			return -1;
 			return -1;
 		t = ms->offset + sizeof(uint32_t);
 		t = ms->offset + sizeof(uint32_t);
 		break;
 		break;
@@ -551,8 +558,8 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_QDATE:
 	case FILE_QDATE:
 	case FILE_BEQDATE:
 	case FILE_BEQDATE:
 	case FILE_LEQDATE:
 	case FILE_LEQDATE:
-		if (file_printf(ms, F(m->desc, "%s"),
-		    file_fmttime(p->q, FILE_T_LOCAL, tbuf)) == -1)
+		if (file_printf(ms, F(ms, m, "%s"),
+		    file_fmttime(p->q + m->num_mask, FILE_T_LOCAL, tbuf)) == -1)
 			return -1;
 			return -1;
 		t = ms->offset + sizeof(uint64_t);
 		t = ms->offset + sizeof(uint64_t);
 		break;
 		break;
@@ -560,8 +567,8 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_QLDATE:
 	case FILE_QLDATE:
 	case FILE_BEQLDATE:
 	case FILE_BEQLDATE:
 	case FILE_LEQLDATE:
 	case FILE_LEQLDATE:
-		if (file_printf(ms, F(m->desc, "%s"),
-		    file_fmttime(p->q, 0, tbuf)) == -1)
+		if (file_printf(ms, F(ms, m, "%s"),
+		    file_fmttime(p->q + m->num_mask, 0, tbuf)) == -1)
 			return -1;
 			return -1;
 		t = ms->offset + sizeof(uint64_t);
 		t = ms->offset + sizeof(uint64_t);
 		break;
 		break;
@@ -569,8 +576,8 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_QWDATE:
 	case FILE_QWDATE:
 	case FILE_BEQWDATE:
 	case FILE_BEQWDATE:
 	case FILE_LEQWDATE:
 	case FILE_LEQWDATE:
-		if (file_printf(ms, F(m->desc, "%s"),
-		    file_fmttime(p->q, FILE_T_WINDOWS, tbuf)) == -1)
+		if (file_printf(ms, F(ms, m, "%s"),
+		    file_fmttime(p->q + m->num_mask, FILE_T_WINDOWS, tbuf)) == -1)
 			return -1;
 			return -1;
 		t = ms->offset + sizeof(uint64_t);
 		t = ms->offset + sizeof(uint64_t);
 		break;
 		break;
@@ -584,11 +591,11 @@ mprint(struct magic_set *ms, struct magic *m)
 			return -1;
 			return -1;
 		case 1:
 		case 1:
 			(void)snprintf(buf, sizeof(buf), "%g", vf);
 			(void)snprintf(buf, sizeof(buf), "%g", vf);
-			if (file_printf(ms, F(m->desc, "%s"), buf) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		default:
 		default:
-			if (file_printf(ms, F(m->desc, "%g"), vf) == -1)
+			if (file_printf(ms, F(ms, m, "%g"), vf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		}
 		}
@@ -604,11 +611,11 @@ mprint(struct magic_set *ms, struct magic *m)
 			return -1;
 			return -1;
 		case 1:
 		case 1:
 			(void)snprintf(buf, sizeof(buf), "%g", vd);
 			(void)snprintf(buf, sizeof(buf), "%g", vd);
-			if (file_printf(ms, F(m->desc, "%s"), buf) == -1)
+			if (file_printf(ms, F(ms, m, "%s"), buf) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		default:
 		default:
-			if (file_printf(ms, F(m->desc, "%g"), vd) == -1)
+			if (file_printf(ms, F(ms, m, "%g"), vd) == -1)
 				return -1;
 				return -1;
 			break;
 			break;
 		}
 		}
@@ -624,7 +631,7 @@ mprint(struct magic_set *ms, struct magic *m)
 			file_oomem(ms, ms->search.rm_len);
 			file_oomem(ms, ms->search.rm_len);
 			return -1;
 			return -1;
 		}
 		}
-		rval = file_printf(ms, F(m->desc, "%s"), cp);
+		rval = file_printf(ms, F(ms, m, "%s"), cp);
 		free(cp);
 		free(cp);
 
 
 		if (rval == -1)
 		if (rval == -1)
@@ -638,7 +645,7 @@ mprint(struct magic_set *ms, struct magic *m)
 	}
 	}
 
 
 	case FILE_SEARCH:
 	case FILE_SEARCH:
-	  	if (file_printf(ms, F(m->desc, "%s"), m->value.s) == -1)
+	  	if (file_printf(ms, F(ms, m, "%s"), m->value.s) == -1)
 			return -1;
 			return -1;
 		if ((m->str_flags & REGEX_OFFSET_START))
 		if ((m->str_flags & REGEX_OFFSET_START))
 			t = ms->search.offset;
 			t = ms->search.offset;
@@ -905,8 +912,9 @@ private int
 mconvert(struct magic_set *ms, struct magic *m, int flip)
 mconvert(struct magic_set *ms, struct magic *m, int flip)
 {
 {
 	union VALUETYPE *p = &ms->ms_value;
 	union VALUETYPE *p = &ms->ms_value;
+	uint8_t type;
 
 
-	switch (cvt_flip(m->type, flip)) {
+	switch (type = cvt_flip(m->type, flip)) {
 	case FILE_BYTE:
 	case FILE_BYTE:
 		cvt_8(p, m);
 		cvt_8(p, m);
 		return 1;
 		return 1;
@@ -932,10 +940,18 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
 		return 1;
 		return 1;
 	}
 	}
 	case FILE_PSTRING: {
 	case FILE_PSTRING: {
-		char *ptr1 = p->s, *ptr2 = ptr1 + file_pstring_length_size(m);
+		size_t sz = file_pstring_length_size(m);
+		char *ptr1 = p->s, *ptr2 = ptr1 + sz;
 		size_t len = file_pstring_get_length(m, ptr1);
 		size_t len = file_pstring_get_length(m, ptr1);
-		if (len >= sizeof(p->s))
-			len = sizeof(p->s) - 1;
+		if (len >= sizeof(p->s)) {
+			/*
+			 * The size of the pascal string length (sz)
+			 * is 1, 2, or 4. We need at least 1 byte for NUL
+			 * termination, but we've already truncated the
+			 * string by p->s, so we need to deduct sz.
+			 */ 
+			len = sizeof(p->s) - sz;
+		}
 		while (len--)
 		while (len--)
 			*ptr1++ = *ptr2++;
 			*ptr1++ = *ptr2++;
 		*ptr1 = '\0';
 		*ptr1 = '\0';
@@ -950,7 +966,8 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
 	case FILE_BELDATE:
 	case FILE_BELDATE:
 		p->l = (int32_t)
 		p->l = (int32_t)
 		    ((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
 		    ((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
-		cvt_32(p, m);
+		if (type == FILE_BELONG)
+			cvt_32(p, m);
 		return 1;
 		return 1;
 	case FILE_BEQUAD:
 	case FILE_BEQUAD:
 	case FILE_BEQDATE:
 	case FILE_BEQDATE:
@@ -961,7 +978,8 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
 		     ((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
 		     ((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
 		     ((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
 		     ((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
 		     ((uint64_t)p->hq[6]<<8)|((uint64_t)p->hq[7]));
 		     ((uint64_t)p->hq[6]<<8)|((uint64_t)p->hq[7]));
-		cvt_64(p, m);
+		if (type == FILE_BEQUAD)
+			cvt_64(p, m);
 		return 1;
 		return 1;
 	case FILE_LESHORT:
 	case FILE_LESHORT:
 		p->h = (short)((p->hs[1]<<8)|(p->hs[0]));
 		p->h = (short)((p->hs[1]<<8)|(p->hs[0]));
@@ -972,7 +990,8 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
 	case FILE_LELDATE:
 	case FILE_LELDATE:
 		p->l = (int32_t)
 		p->l = (int32_t)
 		    ((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
 		    ((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
-		cvt_32(p, m);
+		if (type == FILE_LELONG)
+			cvt_32(p, m);
 		return 1;
 		return 1;
 	case FILE_LEQUAD:
 	case FILE_LEQUAD:
 	case FILE_LEQDATE:
 	case FILE_LEQDATE:
@@ -983,14 +1002,16 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
 		     ((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
 		     ((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
 		     ((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
 		     ((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
 		     ((uint64_t)p->hq[1]<<8)|((uint64_t)p->hq[0]));
 		     ((uint64_t)p->hq[1]<<8)|((uint64_t)p->hq[0]));
-		cvt_64(p, m);
+		if (type == FILE_LEQUAD)
+			cvt_64(p, m);
 		return 1;
 		return 1;
 	case FILE_MELONG:
 	case FILE_MELONG:
 	case FILE_MEDATE:
 	case FILE_MEDATE:
 	case FILE_MELDATE:
 	case FILE_MELDATE:
 		p->l = (int32_t)
 		p->l = (int32_t)
 		    ((p->hl[1]<<24)|(p->hl[0]<<16)|(p->hl[3]<<8)|(p->hl[2]));
 		    ((p->hl[1]<<24)|(p->hl[0]<<16)|(p->hl[3]<<8)|(p->hl[2]));
-		cvt_32(p, m);
+		if (type == FILE_MELONG)
+			cvt_32(p, m);
 		return 1;
 		return 1;
 	case FILE_FLOAT:
 	case FILE_FLOAT:
 		cvt_float(p, m);
 		cvt_float(p, m);
@@ -1047,7 +1068,7 @@ mdebug(uint32_t offset, const char *str, size_t len)
 
 
 private int
 private int
 mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
-    const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt)
+    const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m)
 {
 {
 	/*
 	/*
 	 * Note: FILE_SEARCH and FILE_REGEX do not actually copy
 	 * Note: FILE_SEARCH and FILE_REGEX do not actually copy
@@ -1067,15 +1088,29 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 			const char *last;	/* end of search region */
 			const char *last;	/* end of search region */
 			const char *buf;	/* start of search region */
 			const char *buf;	/* start of search region */
 			const char *end;
 			const char *end;
-			size_t lines;
+			size_t lines, linecnt, bytecnt;
 
 
 			if (s == NULL) {
 			if (s == NULL) {
 				ms->search.s_len = 0;
 				ms->search.s_len = 0;
 				ms->search.s = NULL;
 				ms->search.s = NULL;
 				return 0;
 				return 0;
 			}
 			}
+
+			if (m->str_flags & REGEX_LINE_COUNT) {
+				linecnt = m->str_range;
+				bytecnt = linecnt * 80;
+			} else {
+				linecnt = 0;
+				bytecnt = m->str_range;
+			}
+
+			if (bytecnt == 0)
+				bytecnt = 8192;
+			if (bytecnt > nbytes)
+				bytecnt = nbytes;
+
 			buf = RCAST(const char *, s) + offset;
 			buf = RCAST(const char *, s) + offset;
-			end = last = RCAST(const char *, s) + nbytes;
+			end = last = RCAST(const char *, s) + bytecnt;
 			/* mget() guarantees buf <= last */
 			/* mget() guarantees buf <= last */
 			for (lines = linecnt, b = buf; lines && b < end &&
 			for (lines = linecnt, b = buf; lines && b < end &&
 			     ((b = CAST(const char *,
 			     ((b = CAST(const char *,
@@ -1088,7 +1123,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 					b++;
 					b++;
 			}
 			}
 			if (lines)
 			if (lines)
-				last = RCAST(const char *, s) + nbytes;
+				last = RCAST(const char *, s) + bytecnt;
 
 
 			ms->search.s = buf;
 			ms->search.s = buf;
 			ms->search.s_len = last - buf;
 			ms->search.s_len = last - buf;
@@ -1159,7 +1194,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
     int *need_separator, int *returnval)
     int *need_separator, int *returnval)
 {
 {
 	uint32_t soffset, offset = ms->offset;
 	uint32_t soffset, offset = ms->offset;
-	uint32_t count = m->str_range;
+	uint32_t lhs;
 	int rv, oneed_separator, in_type;
 	int rv, oneed_separator, in_type;
 	char *sbuf, *rbuf;
 	char *sbuf, *rbuf;
 	union VALUETYPE *p = &ms->ms_value;
 	union VALUETYPE *p = &ms->ms_value;
@@ -1171,13 +1206,12 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
 	}
 	}
 
 
 	if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
 	if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
-	    (uint32_t)nbytes, count) == -1)
+	    (uint32_t)nbytes, m) == -1)
 		return -1;
 		return -1;
 
 
 	if ((ms->flags & MAGIC_DEBUG) != 0) {
 	if ((ms->flags & MAGIC_DEBUG) != 0) {
 		fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
 		fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
-		    "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
-		    nbytes, count);
+		    "nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes);
 		mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
 		mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
 #ifndef COMPILE_ONLY
 #ifndef COMPILE_ONLY
 		file_mdump(m);
 		file_mdump(m);
@@ -1262,104 +1296,72 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
 		case FILE_BESHORT:
 		case FILE_BESHORT:
 			if (OFFSET_OOB(nbytes, offset, 2))
 			if (OFFSET_OOB(nbytes, offset, 2))
 				return 0;
 				return 0;
+			lhs = (p->hs[0] << 8) | p->hs[1];
 			if (off) {
 			if (off) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				case FILE_OPAND:
 				case FILE_OPAND:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) &
-						 off;
+					offset = lhs & off;
 					break;
 					break;
 				case FILE_OPOR:
 				case FILE_OPOR:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) |
-						 off;
+					offset = lhs | off;
 					break;
 					break;
 				case FILE_OPXOR:
 				case FILE_OPXOR:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) ^
-						 off;
+					offset = lhs ^ off;
 					break;
 					break;
 				case FILE_OPADD:
 				case FILE_OPADD:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) +
-						 off;
+					offset = lhs + off;
 					break;
 					break;
 				case FILE_OPMINUS:
 				case FILE_OPMINUS:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) -
-						 off;
+					offset = lhs - off;
 					break;
 					break;
 				case FILE_OPMULTIPLY:
 				case FILE_OPMULTIPLY:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) *
-						 off;
+					offset = lhs * off;
 					break;
 					break;
 				case FILE_OPDIVIDE:
 				case FILE_OPDIVIDE:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) /
-						 off;
+					offset = lhs / off;
 					break;
 					break;
 				case FILE_OPMODULO:
 				case FILE_OPMODULO:
-					offset = (short)((p->hs[0]<<8)|
-							 (p->hs[1])) %
-						 off;
+					offset = lhs % off;
 					break;
 					break;
 				}
 				}
 			} else
 			} else
-				offset = (short)((p->hs[0]<<8)|
-						 (p->hs[1]));
+				offset = lhs;
 			if (m->in_op & FILE_OPINVERSE)
 			if (m->in_op & FILE_OPINVERSE)
 				offset = ~offset;
 				offset = ~offset;
 			break;
 			break;
 		case FILE_LESHORT:
 		case FILE_LESHORT:
 			if (OFFSET_OOB(nbytes, offset, 2))
 			if (OFFSET_OOB(nbytes, offset, 2))
 				return 0;
 				return 0;
+			lhs = (p->hs[1] << 8) | p->hs[0];
 			if (off) {
 			if (off) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				case FILE_OPAND:
 				case FILE_OPAND:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) &
-						 off;
+					offset = lhs & off;
 					break;
 					break;
 				case FILE_OPOR:
 				case FILE_OPOR:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) |
-						 off;
+					offset = lhs | off;
 					break;
 					break;
 				case FILE_OPXOR:
 				case FILE_OPXOR:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) ^
-						 off;
+					offset = lhs ^ off;
 					break;
 					break;
 				case FILE_OPADD:
 				case FILE_OPADD:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) +
-						 off;
+					offset = lhs + off;
 					break;
 					break;
 				case FILE_OPMINUS:
 				case FILE_OPMINUS:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) -
-						 off;
+					offset = lhs - off;
 					break;
 					break;
 				case FILE_OPMULTIPLY:
 				case FILE_OPMULTIPLY:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) *
-						 off;
+					offset = lhs * off;
 					break;
 					break;
 				case FILE_OPDIVIDE:
 				case FILE_OPDIVIDE:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) /
-						 off;
+					offset = lhs / off;
 					break;
 					break;
 				case FILE_OPMODULO:
 				case FILE_OPMODULO:
-					offset = (short)((p->hs[1]<<8)|
-							 (p->hs[0])) %
-						 off;
+					offset = lhs % off;
 					break;
 					break;
 				}
 				}
 			} else
 			} else
-				offset = (short)((p->hs[1]<<8)|
-						 (p->hs[0]));
+				offset = lhs;
 			if (m->in_op & FILE_OPINVERSE)
 			if (m->in_op & FILE_OPINVERSE)
 				offset = ~offset;
 				offset = ~offset;
 			break;
 			break;
@@ -1403,70 +1405,37 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
 		case FILE_BEID3:
 		case FILE_BEID3:
 			if (OFFSET_OOB(nbytes, offset, 4))
 			if (OFFSET_OOB(nbytes, offset, 4))
 				return 0;
 				return 0;
+			lhs = (p->hl[0] << 24) | (p->hl[1] << 16) |
+			    (p->hl[2] << 8) | p->hl[3];
 			if (off) {
 			if (off) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				case FILE_OPAND:
 				case FILE_OPAND:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) &
-						 off;
+					offset = lhs & off;
 					break;
 					break;
 				case FILE_OPOR:
 				case FILE_OPOR:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) |
-						 off;
+					offset = lhs | off;
 					break;
 					break;
 				case FILE_OPXOR:
 				case FILE_OPXOR:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) ^
-						 off;
+					offset = lhs ^ off;
 					break;
 					break;
 				case FILE_OPADD:
 				case FILE_OPADD:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) +
-						 off;
+					offset = lhs + off;
 					break;
 					break;
 				case FILE_OPMINUS:
 				case FILE_OPMINUS:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) -
-						 off;
+					offset = lhs - off;
 					break;
 					break;
 				case FILE_OPMULTIPLY:
 				case FILE_OPMULTIPLY:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) *
-						 off;
+					offset = lhs * off;
 					break;
 					break;
 				case FILE_OPDIVIDE:
 				case FILE_OPDIVIDE:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) /
-						 off;
+					offset = lhs / off;
 					break;
 					break;
 				case FILE_OPMODULO:
 				case FILE_OPMODULO:
-					offset = (int32_t)((p->hl[0]<<24)|
-							 (p->hl[1]<<16)|
-							 (p->hl[2]<<8)|
-							 (p->hl[3])) %
-						 off;
+					offset = lhs % off;
 					break;
 					break;
 				}
 				}
 			} else
 			} else
-				offset = (int32_t)((p->hl[0]<<24)|
-						 (p->hl[1]<<16)|
-						 (p->hl[2]<<8)|
-						 (p->hl[3]));
+				offset = lhs;
 			if (m->in_op & FILE_OPINVERSE)
 			if (m->in_op & FILE_OPINVERSE)
 				offset = ~offset;
 				offset = ~offset;
 			break;
 			break;
@@ -1474,140 +1443,74 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
 		case FILE_LEID3:
 		case FILE_LEID3:
 			if (OFFSET_OOB(nbytes, offset, 4))
 			if (OFFSET_OOB(nbytes, offset, 4))
 				return 0;
 				return 0;
+			lhs = (p->hl[3] << 24) | (p->hl[2] << 16) |
+			    (p->hl[1] << 8) | p->hl[0];
 			if (off) {
 			if (off) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				case FILE_OPAND:
 				case FILE_OPAND:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) &
-						 off;
+					offset = lhs & off;
 					break;
 					break;
 				case FILE_OPOR:
 				case FILE_OPOR:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) |
-						 off;
+					offset = lhs | off;
 					break;
 					break;
 				case FILE_OPXOR:
 				case FILE_OPXOR:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) ^
-						 off;
+					offset = lhs ^ off;
 					break;
 					break;
 				case FILE_OPADD:
 				case FILE_OPADD:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) +
-						 off;
+					offset = lhs + off;
 					break;
 					break;
 				case FILE_OPMINUS:
 				case FILE_OPMINUS:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) -
-						 off;
+					offset = lhs - off;
 					break;
 					break;
 				case FILE_OPMULTIPLY:
 				case FILE_OPMULTIPLY:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) *
-						 off;
+					offset = lhs * off;
 					break;
 					break;
 				case FILE_OPDIVIDE:
 				case FILE_OPDIVIDE:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) /
-						 off;
+					offset = lhs / off;
 					break;
 					break;
 				case FILE_OPMODULO:
 				case FILE_OPMODULO:
-					offset = (int32_t)((p->hl[3]<<24)|
-							 (p->hl[2]<<16)|
-							 (p->hl[1]<<8)|
-							 (p->hl[0])) %
-						 off;
+					offset = lhs % off;
 					break;
 					break;
 				}
 				}
 			} else
 			} else
-				offset = (int32_t)((p->hl[3]<<24)|
-						 (p->hl[2]<<16)|
-						 (p->hl[1]<<8)|
-						 (p->hl[0]));
+				offset = lhs;
 			if (m->in_op & FILE_OPINVERSE)
 			if (m->in_op & FILE_OPINVERSE)
 				offset = ~offset;
 				offset = ~offset;
 			break;
 			break;
 		case FILE_MELONG:
 		case FILE_MELONG:
 			if (OFFSET_OOB(nbytes, offset, 4))
 			if (OFFSET_OOB(nbytes, offset, 4))
 				return 0;
 				return 0;
+			lhs = (p->hl[1] << 24) | (p->hl[0] << 16) |
+			    (p->hl[3] << 8) | p->hl[2];
 			if (off) {
 			if (off) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				switch (m->in_op & FILE_OPS_MASK) {
 				case FILE_OPAND:
 				case FILE_OPAND:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) &
-						 off;
+					offset = lhs & off;
 					break;
 					break;
 				case FILE_OPOR:
 				case FILE_OPOR:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) |
-						 off;
+					offset = lhs | off;
 					break;
 					break;
 				case FILE_OPXOR:
 				case FILE_OPXOR:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) ^
-						 off;
+					offset = lhs ^ off;
 					break;
 					break;
 				case FILE_OPADD:
 				case FILE_OPADD:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) +
-						 off;
+					offset = lhs + off;
 					break;
 					break;
 				case FILE_OPMINUS:
 				case FILE_OPMINUS:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) -
-						 off;
+					offset = lhs - off;
 					break;
 					break;
 				case FILE_OPMULTIPLY:
 				case FILE_OPMULTIPLY:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) *
-						 off;
+					offset = lhs * off;
 					break;
 					break;
 				case FILE_OPDIVIDE:
 				case FILE_OPDIVIDE:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) /
-						 off;
+					offset = lhs / off;
 					break;
 					break;
 				case FILE_OPMODULO:
 				case FILE_OPMODULO:
-					offset = (int32_t)((p->hl[1]<<24)|
-							 (p->hl[0]<<16)|
-							 (p->hl[3]<<8)|
-							 (p->hl[2])) %
-						 off;
+					offset = lhs % off;
 					break;
 					break;
 				}
 				}
 			} else
 			} else
-				offset = (int32_t)((p->hl[1]<<24)|
-						 (p->hl[0]<<16)|
-						 (p->hl[3]<<8)|
-						 (p->hl[2]));
+				offset = lhs;
 			if (m->in_op & FILE_OPINVERSE)
 			if (m->in_op & FILE_OPINVERSE)
 				offset = ~offset;
 				offset = ~offset;
 			break;
 			break;
@@ -1673,7 +1576,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
 			if ((ms->flags & MAGIC_DEBUG) != 0)
 			if ((ms->flags & MAGIC_DEBUG) != 0)
 				fprintf(stderr, "indirect +offs=%u\n", offset);
 				fprintf(stderr, "indirect +offs=%u\n", offset);
 		}
 		}
-		if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)
+		if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1)
 			return -1;
 			return -1;
 		ms->offset = offset;
 		ms->offset = offset;
 
 
@@ -1756,7 +1659,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
 		ms->offset = soffset;
 		ms->offset = soffset;
 		if (rv == 1) {
 		if (rv == 1) {
 			if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
 			if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
-			    file_printf(ms, F(m->desc, "%u"), offset) == -1) {
+			    file_printf(ms, F(ms, m, "%u"), offset) == -1) {
 				free(rbuf);
 				free(rbuf);
 				return -1;
 				return -1;
 			}
 			}
@@ -1889,7 +1792,6 @@ magiccheck(struct magic_set *ms, struct magic *m)
 	double dl, dv;
 	double dl, dv;
 	int matched;
 	int matched;
 	union VALUETYPE *p = &ms->ms_value;
 	union VALUETYPE *p = &ms->ms_value;
-	char *old_lc_ctype;
 
 
 	switch (m->type) {
 	switch (m->type) {
 	case FILE_BYTE:
 	case FILE_BYTE:
@@ -1959,7 +1861,6 @@ magiccheck(struct magic_set *ms, struct magic *m)
 			break;
 			break;
 
 
 		default:
 		default:
-			matched = 0;
 			file_magerror(ms, "cannot happen with float: invalid relation `%c'",
 			file_magerror(ms, "cannot happen with float: invalid relation `%c'",
 			    m->reln);
 			    m->reln);
 			return -1;
 			return -1;
@@ -1993,7 +1894,6 @@ magiccheck(struct magic_set *ms, struct magic *m)
 			break;
 			break;
 
 
 		default:
 		default:
-			matched = 0;
 			file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
 			file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
 			return -1;
 			return -1;
 		}
 		}
@@ -2032,7 +1932,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
 			if (slen + idx > ms->search.s_len)
 			if (slen + idx > ms->search.s_len)
 				break;
 				break;
 
 
-			v = file_strncmp(m->value.s, ms->search.s + idx, slen, m->str_flags);
+			v = file_strncmp(m->value.s, ms->search.s + idx, slen,
+			    m->str_flags);
 			if (v == 0) {	/* found match */
 			if (v == 0) {	/* found match */
 				ms->search.offset += idx;
 				ms->search.offset += idx;
 				break;
 				break;
@@ -2042,39 +1943,33 @@ magiccheck(struct magic_set *ms, struct magic *m)
 	}
 	}
 	case FILE_REGEX: {
 	case FILE_REGEX: {
 		int rc;
 		int rc;
-		regex_t rx;
-		char errmsg[512];
+		file_regex_t rx;
 
 
 		if (ms->search.s == NULL)
 		if (ms->search.s == NULL)
 			return 0;
 			return 0;
 
 
-		old_lc_ctype = setlocale(LC_CTYPE, NULL);
-		assert(old_lc_ctype != NULL);
-		old_lc_ctype = strdup(old_lc_ctype);
-		assert(old_lc_ctype != NULL);
-		(void)setlocale(LC_CTYPE, "C");
 		l = 0;
 		l = 0;
-		rc = regcomp(&rx, m->value.s,
+		rc = file_regcomp(&rx, m->value.s,
 		    REG_EXTENDED|REG_NEWLINE|
 		    REG_EXTENDED|REG_NEWLINE|
 		    ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
 		    ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
 		if (rc) {
 		if (rc) {
-			(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
-			file_magerror(ms, "regex error %d, (%s)",
-			    rc, errmsg);
+			file_regerror(&rx, rc, ms);
 			v = (uint64_t)-1;
 			v = (uint64_t)-1;
-		}
-		else {
+		} else {
 			regmatch_t pmatch[1];
 			regmatch_t pmatch[1];
+			size_t slen = ms->search.s_len;
 #ifndef REG_STARTEND
 #ifndef REG_STARTEND
 #define	REG_STARTEND	0
 #define	REG_STARTEND	0
-			size_t l = ms->search.s_len - 1;
-			char c = ms->search.s[l];
-			((char *)(intptr_t)ms->search.s)[l] = '\0';
+			char c;
+			if (slen != 0)
+				slen--;
+			c = ms->search.s[slen];
+			((char *)(intptr_t)ms->search.s)[slen] = '\0';
 #else
 #else
 			pmatch[0].rm_so = 0;
 			pmatch[0].rm_so = 0;
-			pmatch[0].rm_eo = ms->search.s_len;
+			pmatch[0].rm_eo = slen;
 #endif
 #endif
-			rc = regexec(&rx, (const char *)ms->search.s,
+			rc = file_regexec(&rx, (const char *)ms->search.s,
 			    1, pmatch, REG_STARTEND);
 			    1, pmatch, REG_STARTEND);
 #if REG_STARTEND == 0
 #if REG_STARTEND == 0
 			((char *)(intptr_t)ms->search.s)[l] = c;
 			((char *)(intptr_t)ms->search.s)[l] = c;
@@ -2093,16 +1988,12 @@ magiccheck(struct magic_set *ms, struct magic *m)
 				break;
 				break;
 
 
 			default:
 			default:
-				(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
-				file_magerror(ms, "regexec error %d, (%s)",
-				    rc, errmsg);
+				file_regerror(&rx, rc, ms);
 				v = (uint64_t)-1;
 				v = (uint64_t)-1;
 				break;
 				break;
 			}
 			}
-			regfree(&rx);
 		}
 		}
-		(void)setlocale(LC_CTYPE, old_lc_ctype);
-		free(old_lc_ctype);
+		file_regfree(&rx);
 		if (v == (uint64_t)-1)
 		if (v == (uint64_t)-1)
 			return -1;
 			return -1;
 		break;
 		break;
@@ -2199,7 +2090,6 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		break;
 		break;
 
 
 	default:
 	default:
-		matched = 0;
 		file_magerror(ms, "cannot happen: invalid relation `%c'",
 		file_magerror(ms, "cannot happen: invalid relation `%c'",
 		    m->reln);
 		    m->reln);
 		return -1;
 		return -1;

+ 2 - 0
src/strcasestr.c

@@ -37,6 +37,8 @@ __RCSID("$NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
 __RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
 __RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 #endif /* LIBC_SCCS and not lint */
 
 
+#include "file.h"
+
 #include <assert.h>
 #include <assert.h>
 #include <ctype.h>
 #include <ctype.h>
 #include <string.h>
 #include <string.h>

+ 5 - 8
src/vasprintf.c

@@ -108,7 +108,7 @@ you use strange formats.
 #include "file.h"
 #include "file.h"
 
 
 #ifndef	lint
 #ifndef	lint
-FILE_RCSID("@(#)$File: vasprintf.c,v 1.10 2012/08/09 16:40:04 christos Exp $")
+FILE_RCSID("@(#)$File: vasprintf.c,v 1.12 2014/05/14 23:09:21 christos Exp $")
 #endif	/* lint */
 #endif	/* lint */
 
 
 #include <assert.h>
 #include <assert.h>
@@ -559,7 +559,7 @@ static int dispatch(xprintf_struct *s)
  */
  */
 static int core(xprintf_struct *s)
 static int core(xprintf_struct *s)
 {
 {
-  size_t len, save_len;
+  size_t save_len;
   char *dummy_base;
   char *dummy_base;
 
 
   /* basic checks */
   /* basic checks */
@@ -584,8 +584,7 @@ static int core(xprintf_struct *s)
   for (;;) {
   for (;;) {
     /* up to end of source string */
     /* up to end of source string */
     if (*(s->src_string) == 0) {
     if (*(s->src_string) == 0) {
-      *(s->dest_string) = 0;    /* final 0 */
-      len = s->real_len + 1;
+      *(s->dest_string) = '\0';    /* final NUL */
       break;
       break;
     }
     }
 
 
@@ -594,15 +593,13 @@ static int core(xprintf_struct *s)
 
 
     /* up to end of dest string */
     /* up to end of dest string */
     if (s->real_len >= s->maxlen) {
     if (s->real_len >= s->maxlen) {
-      (s->buffer_base)[s->maxlen] = 0; /* final 0 */
-      len = s->maxlen + 1;
+      (s->buffer_base)[s->maxlen] = '\0'; /* final NUL */
       break;
       break;
     }
     }
   }
   }
 
 
   /* for (v)asnprintf */
   /* for (v)asnprintf */
   dummy_base = s->buffer_base;
   dummy_base = s->buffer_base;
-  save_len = 0;                 /* just to avoid a compiler warning */
 
 
   dummy_base = s->buffer_base + s->real_len;
   dummy_base = s->buffer_base + s->real_len;
   save_len = s->real_len;
   save_len = s->real_len;
@@ -639,7 +636,7 @@ int vasprintf(char **ptr, const char *format_string, va_list vargs)
 #ifdef __va_copy
 #ifdef __va_copy
   __va_copy (s.vargs, vargs);
   __va_copy (s.vargs, vargs);
 #else
 #else
-  memcpy (&s.vargs, vargs, sizeof (va_list));
+  memcpy (&s.vargs, &vargs, sizeof (s.va_args));
 #endif /* __va_copy */
 #endif /* __va_copy */
 #endif /* va_copy */
 #endif /* va_copy */
   s.maxlen = (size_t)INT_MAX;
   s.maxlen = (size_t)INT_MAX;