Module Name:    src
Committed By:   christos
Date:           Mon Oct 20 21:48:57 UTC 2014

Modified Files:
        src/external/bsd/file/dist: ChangeLog configure.ac
        src/external/bsd/file/dist/magic/magdir: elf pgp
        src/external/bsd/file/dist/src: apprentice.c file.c file.h fsmagic.c
            readelf.c

Log Message:
sync with head of upstream to fix MacOS/X compilation and more.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.9 -r1.2 src/external/bsd/file/dist/ChangeLog
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/file/dist/configure.ac
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/file/dist/magic/magdir/elf
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/file/dist/magic/magdir/pgp
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/file/dist/src/apprentice.c \
    src/external/bsd/file/dist/src/file.h
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/file/dist/src/file.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/file/dist/src/fsmagic.c \
    src/external/bsd/file/dist/src/readelf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/file/dist/ChangeLog
diff -u src/external/bsd/file/dist/ChangeLog:1.1.1.9 src/external/bsd/file/dist/ChangeLog:1.2
--- src/external/bsd/file/dist/ChangeLog:1.1.1.9	Fri Oct 10 16:08:15 2014
+++ src/external/bsd/file/dist/ChangeLog	Mon Oct 20 17:48:57 2014
@@ -1,3 +1,12 @@
+2014-10-17  11:48  Christos Zoulas <[email protected]>
+
+	* fix bounds in note reading (Francisco Alonso / Red Hat)
+
+2014-10-11  15:02  Christos Zoulas <[email protected]>
+
+	* fix autoconf glue for setlocale and locale_t; some OS's
+	  have locale_t in xlocale.h
+
 2014-10-10  15:01  Christos Zoulas <[email protected]>
 
 	* release 5.20

Index: src/external/bsd/file/dist/configure.ac
diff -u src/external/bsd/file/dist/configure.ac:1.9 src/external/bsd/file/dist/configure.ac:1.10
--- src/external/bsd/file/dist/configure.ac:1.9	Fri Oct 10 16:15:01 2014
+++ src/external/bsd/file/dist/configure.ac	Mon Oct 20 17:48:57 2014
@@ -83,7 +83,7 @@ AC_HEADER_MAJOR
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
 AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
-AC_CHECK_HEADERS(getopt.h err.h)
+AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
 AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
 AC_CHECK_HEADERS(zlib.h)
 
@@ -139,7 +139,7 @@ else
 fi])
 
 dnl Checks for functions
-AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale)
+AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale)
 
 dnl Provide implementation of some required functions if necessary
 AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r pread strcasestr fmtcheck)

Index: src/external/bsd/file/dist/magic/magdir/elf
diff -u src/external/bsd/file/dist/magic/magdir/elf:1.11 src/external/bsd/file/dist/magic/magdir/elf:1.12
--- src/external/bsd/file/dist/magic/magdir/elf:1.11	Fri Oct 10 16:15:01 2014
+++ src/external/bsd/file/dist/magic/magdir/elf	Mon Oct 20 17:48:57 2014
@@ -30,7 +30,6 @@
 #>>>(0x38+0xcc) string	>\0		of '%s'
 #>>>(0x38+0x10) lelong	>0		(signal %d),
 >16	leshort		&0xff00		processor-specific,
->18	clear		x
 >18	leshort		0		no machine,
 >18	leshort		1		AT&T WE32100,
 >18	leshort		2		SPARC,

Index: src/external/bsd/file/dist/magic/magdir/pgp
diff -u src/external/bsd/file/dist/magic/magdir/pgp:1.1.1.2 src/external/bsd/file/dist/magic/magdir/pgp:1.2
--- src/external/bsd/file/dist/magic/magdir/pgp:1.1.1.2	Thu May 12 16:47:04 2011
+++ src/external/bsd/file/dist/magic/magdir/pgp	Mon Oct 20 17:48:57 2014
@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: pgp,v 1.9 2009/09/19 16:28:11 christos Exp $
+# $File: pgp,v 1.10 2014/10/14 16:50:37 christos Exp $
 # pgp:  file(1) magic for Pretty Good Privacy
 # see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
 #
@@ -25,3 +25,391 @@
 !:mime	application/pgp
 0	string	-----BEGIN\040PGP\40SIGNATURE-		PGP signature
 !:mime	application/pgp-signature
+
+# magic signatures to detect PGP crypto material (from stef)
+# detects and extracts metadata from:
+#  - symmetric encrypted packet header
+#  - RSA (e=65537) secret (sub-)keys
+
+# 1024b RSA encrypted data
+
+0	string	\x84\x8c\x03		PGP RSA encrypted session key -
+>3	lelong	x			keyid: %X
+>7	lelong	x			%X
+>11	byte	0x01			RSA (Encrypt or Sign) 1024b
+>11	byte	0x02			RSA Encrypt-Only 1024b
+>12	string	\x04\x00
+>12	string	\x03\xff
+>12	string	\x03\xfe
+>12	string	\x03\xfd
+>12	string	\x03\xfc
+>12	string	\x03\xfb
+>12	string	\x03\xfa
+>12	string	\x03\xf9
+>142	byte	0xd2			.
+
+# 2048b RSA encrypted data
+
+0	string	\x85\x01\x0c\x03	PGP RSA encrypted session key -
+>4	lelong	x			keyid: %X
+>8	lelong	x			%X
+>12	byte	0x01			RSA (Encrypt or Sign) 2048b
+>12	byte	0x02			RSA Encrypt-Only 2048b
+>13	string	\x08\x00
+>13	string	\x07\xff
+>13	string	\x07\xfe
+>13	string	\x07\xfd
+>13	string	\x07\xfc
+>13	string	\x07\xfb
+>13	string	\x07\xfa
+>13	string	\x07\xf9
+>271	byte	0xd2			.
+
+# 3072b RSA encrypted data
+
+0	string	\x85\x01\x8c\x03	PGP RSA encrypted session key -
+>4	lelong	x			keyid: %X
+>8	lelong	x			%X
+>12	byte	0x01			RSA (Encrypt or Sign) 3072b
+>12	byte	0x02			RSA Encrypt-Only 3072b
+>13	string	\x0c\x00
+>13	string	\x0b\xff
+>13	string	\x0b\xfe
+>13	string	\x0b\xfd
+>13	string	\x0b\xfc
+>13	string	\x0b\xfb
+>13	string	\x0b\xfa
+>13	string	\x0b\xf9
+>399	byte	0xd2			.
+
+# 3072b RSA encrypted data
+
+0	string	\x85\x02\x0c\x03	PGP RSA encrypted session key -
+>4	lelong	x			keyid: %X
+>8	lelong	x			%X
+>12	byte	0x01			RSA (Encrypt or Sign) 4096b
+>12	byte	0x02			RSA Encrypt-Only 4096b
+>13	string	\x10\x00
+>13	string	\x0f\xff
+>13	string	\x0f\xfe
+>13	string	\x0f\xfd
+>13	string	\x0f\xfc
+>13	string	\x0f\xfb
+>13	string	\x0f\xfa
+>13	string	\x0f\xf9
+>527	byte	0xd2			.
+
+# 4096b RSA encrypted data
+
+0	string	\x85\x04\x0c\x03	PGP RSA encrypted session key -
+>4	lelong	x			keyid: %X
+>8	lelong	x			%X
+>12	byte	0x01			RSA (Encrypt or Sign) 8129b
+>12	byte	0x02			RSA Encrypt-Only 8129b
+>13	string	\x20\x00
+>13	string	\x1f\xff
+>13	string	\x1f\xfe
+>13	string	\x1f\xfd
+>13	string	\x1f\xfc
+>13	string	\x1f\xfb
+>13	string	\x1f\xfa
+>13	string	\x1f\xf9
+>1039	byte	0xd2			.
+
+# crypto algo mapper
+
+0	name	crypto
+>0	byte	0x00			Plaintext or unencrypted data
+>0	byte	0x01			IDEA
+>0	byte	0x02			TripleDES
+>0	byte	0x03			CAST5 (128 bit key)
+>0	byte	0x04			Blowfish (128 bit key, 16 rounds)
+>0	byte	0x07			AES with 128-bit key
+>0	byte	0x08			AES with 192-bit key
+>0	byte	0x09			AES with 256-bit key
+>0	byte	0x0a			Twofish with 256-bit key
+
+# hash algo mapper
+
+0	name	hash
+>0	byte	0x01			MD5
+>0	byte	0x02			SHA-1
+>0	byte	0x03			RIPE-MD/160
+>0	byte	0x08			SHA256
+>0	byte	0x09			SHA384
+>0	byte	0x0a			SHA512
+>0	byte	0x0b			SHA224
+
+# pgp symmetric encrypted data
+
+0	byte	0x8c			PGP symmetric key encrypted data -
+>1	byte	0x0d
+>1	byte	0x0c
+>2	byte	0x04
+>3	use	crypto
+>4	byte	0x01			salted -
+>>5	use	hash
+>>14	byte	0xd2			.
+>>14	byte	0xc9			.
+>4	byte	0x03			salted & iterated -
+>>5	use	hash
+>>15	byte	0xd2			.
+>>15	byte	0xc9			.
+
+# encrypted keymaterial needs s2k & can be checksummed/hashed
+
+0	name	chkcrypto
+>0	use	crypto
+>1	byte	0x00			Simple S2K
+>1	byte	0x01			Salted S2K
+>1	byte	0x03			Salted&Iterated S2K
+>2	use	hash
+
+# all PGP keys start with this prolog
+# containing version, creation date, and purpose
+
+0	name	keyprolog
+>0	byte	0x04
+>1	beldate	x			created on %s -
+>5	byte	0x01			RSA (Encrypt or Sign)
+>5	byte	0x02			RSA Encrypt-Only
+
+# end of secret keys known signature
+# contains e=65537 and the prolog to
+# the encrypted parameters
+
+0	name	keyend
+>0	string	\x00\x11\x01\x00\x01	e=65537
+>5	use	crypto
+>5	byte	0xff			checksummed
+>>6	use	chkcrypto
+>5	byte	0xfe			hashed
+>>6	use	chkcrypto
+
+# PGP secret keys contain also the public parts
+# these vary by bitsize of the key
+
+0	name	x1024
+>0	use	keyprolog
+>6	string	\x03\xfe
+>6	string	\x03\xff
+>6	string	\x04\x00
+>136	use	keyend
+
+0	name	x2048
+>0	use	keyprolog
+>6	string	\x80\x00
+>6	string	\x07\xfe
+>6	string	\x07\xff
+>264	use	keyend
+
+0	name	x3072
+>0	use	keyprolog
+>6	string	\x0b\xfe
+>6	string	\x0b\xff
+>6	string	\x0c\x00
+>392	use	keyend
+
+0	name	x4096
+>0	use	keyprolog
+>6	string	\x10\x00
+>6	string	\x0f\xfe
+>6	string	\x0f\xff
+>520	use	keyend
+
+# \x00|\x1f[\xfe\xff]).{1024})'
+0	name	x8192
+>0	use	keyprolog
+>6	string	\x20\x00
+>6	string	\x1f\xfe
+>6	string	\x1f\xff
+>1032	use	keyend
+
+# depending on the size of the pkt
+# we branch into the proper key size
+# signatures defined as x{keysize}
+
+>0	name	pgpkey
+>0	string	\x01\xd8	1024b
+>>2	use	x1024
+>0	string	\x01\xeb	1024b
+>>2	use	x1024
+>0	string	\x01\xfb	1024b
+>>2	use	x1024
+>0	string	\x01\xfd	1024b
+>>2	use	x1024
+>0	string	\x01\xf3	1024b
+>>2	use	x1024
+>0	string	\x01\xee	1024b
+>>2	use	x1024
+>0	string	\x01\xfe	1024b
+>>2	use	x1024
+>0	string	\x01\xf4	1024b
+>>2	use	x1024
+>0	string	\x02\x0d	1024b
+>>2	use	x1024
+>0	string	\x02\x03	1024b
+>>2	use	x1024
+>0	string	\x02\x05	1024b
+>>2	use	x1024
+>0	string	\x02\x15	1024b
+>>2	use	x1024
+>0	string	\x02\x00	1024b
+>>2	use	x1024
+>0	string	\x02\x10	1024b
+>>2	use	x1024
+>0	string	\x02\x04	1024b
+>>2	use	x1024
+>0	string	\x02\x06	1024b
+>>2	use	x1024
+>0	string	\x02\x16	1024b
+>>2	use	x1024
+>0	string	\x03\x98	2048b
+>>2	use	x2048
+>0	string	\x03\xab	2048b
+>>2	use	x2048
+>0	string	\x03\xbb	2048b
+>>2	use	x2048
+>0	string	\x03\xbd	2048b
+>>2	use	x2048
+>0	string	\x03\xcd	2048b
+>>2	use	x2048
+>0	string	\x03\xb3	2048b
+>>2	use	x2048
+>0	string	\x03\xc3	2048b
+>>2	use	x2048
+>0	string	\x03\xc5	2048b
+>>2	use	x2048
+>0	string	\x03\xd5	2048b
+>>2	use	x2048
+>0	string	\x03\xae	2048b
+>>2	use	x2048
+>0	string	\x03\xbe	2048b
+>>2	use	x2048
+>0	string	\x03\xc0	2048b
+>>2	use	x2048
+>0	string	\x03\xd0	2048b
+>>2	use	x2048
+>0	string	\x03\xb4	2048b
+>>2	use	x2048
+>0	string	\x03\xc4	2048b
+>>2	use	x2048
+>0	string	\x03\xc6	2048b
+>>2	use	x2048
+>0	string	\x03\xd6	2048b
+>>2	use	x2048
+>0	string	\x05X		3072b
+>>2	use	x3072
+>0	string	\x05k		3072b
+>>2	use	x3072
+>0	string	\x05{		3072b
+>>2	use	x3072
+>0	string	\x05}		3072b
+>>2	use	x3072
+>0	string	\x05\x8d	3072b
+>>2	use	x3072
+>0	string	\x05s		3072b
+>>2	use	x3072
+>0	string	\x05\x83	3072b
+>>2	use	x3072
+>0	string	\x05\x85	3072b
+>>2	use	x3072
+>0	string	\x05\x95	3072b
+>>2	use	x3072
+>0	string	\x05n		3072b
+>>2	use	x3072
+>0	string	\x05\x7e	3072b
+>>2	use	x3072
+>0	string	\x05\x80	3072b
+>>2	use	x3072
+>0	string	\x05\x90	3072b
+>>2	use	x3072
+>0	string	\x05t		3072b
+>>2	use	x3072
+>0	string	\x05\x84	3072b
+>>2	use	x3072
+>0	string	\x05\x86	3072b
+>>2	use	x3072
+>0	string	\x05\x96	3072b
+>>2	use	x3072
+>0	string	\x07[		4096b
+>>2	use	x4096
+>0	string	\x07\x18	4096b
+>>2	use	x4096
+>0	string	\x07+		4096b
+>>2	use	x4096
+>0	string	\x07;		4096b
+>>2	use	x4096
+>0	string	\x07=		4096b
+>>2	use	x4096
+>0	string	\x07M		4096b
+>>2	use	x4096
+>0	string	\x073		4096b
+>>2	use	x4096
+>0	string	\x07C		4096b
+>>2	use	x4096
+>0	string	\x07E		4096b
+>>2	use	x4096
+>0	string	\x07U		4096b
+>>2	use	x4096
+>0	string	\x07.		4096b
+>>2	use	x4096
+>0	string	\x07>		4096b
+>>2	use	x4096
+>0	string	\x07@		4096b
+>>2	use	x4096
+>0	string	\x07P		4096b
+>>2	use	x4096
+>0	string	\x074		4096b
+>>2	use	x4096
+>0	string	\x07D		4096b
+>>2	use	x4096
+>0	string	\x07F		4096b
+>>2	use	x4096
+>0	string	\x07V		4096b
+>>2	use	x4096
+>0	string	\x0e[		8192b
+>>2	use	x8192
+>0	string	\x0e\x18	8192b
+>>2	use	x8192
+>0	string	\x0e+		8192b
+>>2	use	x8192
+>0	string	\x0e;		8192b
+>>2	use	x8192
+>0	string	\x0e=		8192b
+>>2	use	x8192
+>0	string	\x0eM		8192b
+>>2	use	x8192
+>0	string	\x0e3		8192b
+>>2	use	x8192
+>0	string	\x0eC		8192b
+>>2	use	x8192
+>0	string	\x0eE		8192b
+>>2	use	x8192
+>0	string	\x0eU		8192b
+>>2	use	x8192
+>0	string	\x0e.		8192b
+>>2	use	x8192
+>0	string	\x0e>		8192b
+>>2	use	x8192
+>0	string	\x0e@		8192b
+>>2	use	x8192
+>0	string	\x0eP		8192b
+>>2	use	x8192
+>0	string	\x0e4		8192b
+>>2	use	x8192
+>0	string	\x0eD		8192b
+>>2	use	x8192
+>0	string	\x0eF		8192b
+>>2	use	x8192
+>0	string	\x0eV		8192b
+>>2	use	x8192
+
+# PGP RSA (e=65537) secret (sub-)key header
+
+0	byte	0x95			PGP	Secret Key -
+>1	use	pgpkey
+0	byte	0x97			PGP	Secret Sub-key -
+>1	use	pgpkey
+0	byte	0x9d			PGP	Secret Sub-key -
+>1	use	pgpkey

Index: src/external/bsd/file/dist/src/apprentice.c
diff -u src/external/bsd/file/dist/src/apprentice.c:1.12 src/external/bsd/file/dist/src/apprentice.c:1.13
--- src/external/bsd/file/dist/src/apprentice.c:1.12	Fri Oct 10 16:15:02 2014
+++ src/external/bsd/file/dist/src/apprentice.c	Mon Oct 20 17:48:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: apprentice.c,v 1.12 2014/10/10 20:15:02 christos Exp $	*/
+/*	$NetBSD: apprentice.c,v 1.13 2014/10/20 21:48:57 christos Exp $	*/
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
@@ -34,9 +34,9 @@
 
 #ifndef	lint
 #if 0
-FILE_RCSID("@(#)$File: apprentice.c,v 1.216 2014/09/24 19:49:07 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.217 2014/10/15 12:39:21 christos Exp $")
 #else
-__RCSID("$NetBSD: apprentice.c,v 1.12 2014/10/10 20:15:02 christos Exp $");
+__RCSID("$NetBSD: apprentice.c,v 1.13 2014/10/20 21:48:57 christos Exp $");
 #endif
 #endif	/* lint */
 
@@ -1378,7 +1378,7 @@ file_signextend(struct magic_set *ms, st
 		 * the sign extension must have happened.
 		 */
 		case FILE_BYTE:
-			v = (char) v;
+			v = (signed char) v;
 			break;
 		case FILE_SHORT:
 		case FILE_BESHORT:
Index: src/external/bsd/file/dist/src/file.h
diff -u src/external/bsd/file/dist/src/file.h:1.12 src/external/bsd/file/dist/src/file.h:1.13
--- src/external/bsd/file/dist/src/file.h:1.12	Fri Oct 10 16:15:02 2014
+++ src/external/bsd/file/dist/src/file.h	Mon Oct 20 17:48:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: file.h,v 1.12 2014/10/10 20:15:02 christos Exp $	*/
+/*	$NetBSD: file.h,v 1.13 2014/10/20 21:48:57 christos Exp $	*/
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
@@ -28,7 +28,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.154 2014/09/10 18:41:51 christos Exp $
+ * @(#)$File: file.h,v 1.155 2014/10/11 15:03:16 christos Exp $
  */
 
 #ifndef __file_h__
@@ -475,6 +475,9 @@ protected int file_os2_apptype(struct ma
 #if defined(HAVE_LOCALE_H)
 #include <locale.h>
 #endif
+#if defined(HAVE_XLOCALE_H)
+#include <xlocale.h>
+#endif
 
 typedef struct {
 	const char *pat;

Index: src/external/bsd/file/dist/src/file.c
diff -u src/external/bsd/file/dist/src/file.c:1.5 src/external/bsd/file/dist/src/file.c:1.6
--- src/external/bsd/file/dist/src/file.c:1.5	Fri Oct 10 16:15:02 2014
+++ src/external/bsd/file/dist/src/file.c	Mon Oct 20 17:48:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: file.c,v 1.5 2014/10/10 20:15:02 christos Exp $	*/
+/*	$NetBSD: file.c,v 1.6 2014/10/20 21:48:57 christos Exp $	*/
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
@@ -34,9 +34,9 @@
 
 #ifndef	lint
 #if 0
-FILE_RCSID("@(#)$File: file.c,v 1.154 2014/09/10 18:41:51 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.155 2014/10/11 15:03:16 christos Exp $")
 #else
-__RCSID("$NetBSD: file.c,v 1.5 2014/10/10 20:15:02 christos Exp $");
+__RCSID("$NetBSD: file.c,v 1.6 2014/10/20 21:48:57 christos Exp $");
 #endif
 #endif	/* lint */
 
@@ -153,7 +153,9 @@ main(int argc, char *argv[])
 	const char *magicfile = NULL;		/* where the magic is	*/
 
 	/* makes islower etc work for other langs */
+#ifdef HAVE_SETLOCALE
 	(void)setlocale(LC_CTYPE, "");
+#endif
 
 #ifdef __EMX__
 	/* sh-like wildcard expansion! Shouldn't hurt at least ... */

Index: src/external/bsd/file/dist/src/fsmagic.c
diff -u src/external/bsd/file/dist/src/fsmagic.c:1.9 src/external/bsd/file/dist/src/fsmagic.c:1.10
--- src/external/bsd/file/dist/src/fsmagic.c:1.9	Thu Jun 12 22:08:06 2014
+++ src/external/bsd/file/dist/src/fsmagic.c	Mon Oct 20 17:48:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fsmagic.c,v 1.9 2014/06/13 02:08:06 christos Exp $	*/
+/*	$NetBSD: fsmagic.c,v 1.10 2014/10/20 21:48:57 christos Exp $	*/
 /*
  * Copyright (c) Ian F. Darwin 1986-1995.
  * Software written by Ian F. Darwin and others;
@@ -34,9 +34,9 @@
 
 #ifndef	lint
 #if 0
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.73 2014/05/14 23:15:42 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.74 2014/10/13 20:21:49 christos Exp $")
 #else
-__RCSID("$NetBSD: fsmagic.c,v 1.9 2014/06/13 02:08:06 christos Exp $");
+__RCSID("$NetBSD: fsmagic.c,v 1.10 2014/10/20 21:48:57 christos Exp $");
 #endif
 #endif	/* lint */
 
@@ -80,10 +80,10 @@ bad_link(struct magic_set *ms, int err, 
 	else if (!mime) {
 		if (ms->flags & MAGIC_ERROR) {
 			file_error(ms, err,
-				   "broken symbolic link to `%s'", buf);
+				   "broken symbolic link to %s", buf);
 			return -1;
 		} 
-		if (file_printf(ms, "broken symbolic link to `%s'", buf) == -1)
+		if (file_printf(ms, "broken symbolic link to %s", buf) == -1)
 			return -1;
 	}
 	return 1;
@@ -357,7 +357,7 @@ file_fsmagic(struct magic_set *ms, const
 			if (mime) {
 				if (handle_mime(ms, mime, "symlink") == -1)
 					return -1;
-			} else if (file_printf(ms, "%ssymbolic link to `%s'",
+			} else if (file_printf(ms, "%ssymbolic link to %s",
 			    COMMA, buf) == -1)
 				return -1;
 		}
Index: src/external/bsd/file/dist/src/readelf.c
diff -u src/external/bsd/file/dist/src/readelf.c:1.9 src/external/bsd/file/dist/src/readelf.c:1.10
--- src/external/bsd/file/dist/src/readelf.c:1.9	Fri Jun 13 09:38:52 2014
+++ src/external/bsd/file/dist/src/readelf.c	Mon Oct 20 17:48:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: readelf.c,v 1.9 2014/06/13 13:38:52 joerg Exp $	*/
+/*	$NetBSD: readelf.c,v 1.10 2014/10/20 21:48:57 christos Exp $	*/
 /*
  * Copyright (c) Christos Zoulas 2003.
  * All Rights Reserved.
@@ -29,9 +29,9 @@
 
 #ifndef lint
 #if 0
-FILE_RCSID("@(#)$File: readelf.c,v 1.103 2014/05/02 02:25:10 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.104 2014/10/17 15:49:00 christos Exp $")
 #else
-__RCSID("$NetBSD: readelf.c,v 1.9 2014/06/13 13:38:52 joerg Exp $");
+__RCSID("$NetBSD: readelf.c,v 1.10 2014/10/20 21:48:57 christos Exp $");
 #endif
 #endif
 
@@ -482,6 +482,13 @@ donote(struct magic_set *ms, void *vbuf,
 	uint32_t namesz, descsz;
 	unsigned char *nbuf = CAST(unsigned char *, vbuf);
 
+	if (xnh_sizeof + offset > size) {
+		/*
+		 * We're out of note headers.
+		 */
+		return xnh_sizeof + offset;
+	}
+
 	(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
 	offset += xnh_sizeof;
 

Reply via email to