Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/file/dist bring in changes from head.
details: https://anonhg.NetBSD.org/src/rev/f78eee451d4b
branches: trunk
changeset: 778669:f78eee451d4b
user: christos <christos%NetBSD.org@localhost>
date: Sat Apr 07 17:30:55 2012 +0000
description:
bring in changes from head.
diffstat:
external/bsd/file/dist/magic/magdir/apple | 44 ++++++++++++++++++++++++++++++-
external/bsd/file/dist/src/apprentice.c | 9 ++++--
external/bsd/file/dist/src/softmagic.c | 31 +++++++++++++++++----
3 files changed, 74 insertions(+), 10 deletions(-)
diffs (170 lines):
diff -r 9f01209160a6 -r f78eee451d4b external/bsd/file/dist/magic/magdir/apple
--- a/external/bsd/file/dist/magic/magdir/apple Sat Apr 07 17:28:44 2012 +0000
+++ b/external/bsd/file/dist/magic/magdir/apple Sat Apr 07 17:30:55 2012 +0000
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
-# $File: apple,v 1.24 2010/11/25 15:00:12 christos Exp $
+# $File: apple,v 1.25 2012/04/06 21:18:09 christos Exp $
# apple: file(1) magic for Apple file formats
#
0 search/1/t FiLeStArTfIlEsTaRt binscii (apple ][) text
@@ -249,3 +249,45 @@
# From: "Nelson A. de Oliveira" <naoliv%gmail.com@localhost>
# .vdi
4 string innotek\ VirtualBox\ Disk\ Image %s
+
+# Apple disk partition stuff, strengthen the magic using byte 4
+0 beshort 0x4552
+>4 byte 0 Apple Driver Map
+>>2 beshort x \b, blocksize %d
+>>4 belong x \b, blockcount %d
+>>10 beshort x \b, devtype %d
+>>12 beshort x \b, devid %d
+>>20 beshort x \b, descriptors %d
+# Assume 8 partitions each at a multiple of the sector size.
+# We could glean this from the partition descriptors, but they are empty!?!?
+>>(2.S*1) indirect \b, contains[@0x%x]:
+>>(2.S*2) indirect \b, contains[@0x%x]:
+>>(2.S*3) indirect \b, contains[@0x%x]:
+>>(2.S*4) indirect \b, contains[@0x%x]:
+>>(2.S*5) indirect \b, contains[@0x%x]:
+>>(2.S*6) indirect \b, contains[@0x%x]:
+>>(2.S*7) indirect \b, contains[@0x%x]:
+>>(2.S*8) indirect \b, contains[@0x%x]:
+
+# Yes, the 3rd and 4th bytes are reserved, but we use them to make the
+# magic stronger.
+0 belong 0x504d0000 Apple Partition Map
+>4 belong x \b, map block count %d
+>8 belong x \b, start block %d
+>12 belong x \b, block count %d
+>16 string >0 \b, name %s
+>48 string >0 \b, type %s
+>124 string >0 \b, processor %s
+>140 string >0 \b, boot arguments %s
+>92 belong & 1 \b, valid
+>92 belong & 2 \b, allocated
+>92 belong & 4 \b, in use
+>92 belong & 8 \b, has boot info
+>92 belong & 16 \b, readable
+>92 belong & 32 \b, writable
+>92 belong & 64 \b, pic boot code
+>92 belong & 128 \b, chain compatible driver
+>92 belong & 256 \b, real driver
+>92 belong & 512 \b, chain driver
+>92 belong & 1024 \b, mount at startup
+>92 belong & 2048 \b, is the startup partition
diff -r 9f01209160a6 -r f78eee451d4b external/bsd/file/dist/src/apprentice.c
--- a/external/bsd/file/dist/src/apprentice.c Sat Apr 07 17:28:44 2012 +0000
+++ b/external/bsd/file/dist/src/apprentice.c Sat Apr 07 17:30:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apprentice.c,v 1.6 2012/02/22 17:53:51 christos Exp $ */
+/* $NetBSD: apprentice.c,v 1.7 2012/04/07 17:30:55 christos Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
@@ -37,7 +37,7 @@
#if 0
FILE_RCSID("@(#)$File: apprentice.c,v 1.173 2011/12/08 12:38:24 rrt Exp $")
#else
-__RCSID("$NetBSD: apprentice.c,v 1.6 2012/02/22 17:53:51 christos Exp $");
+__RCSID("$NetBSD: apprentice.c,v 1.7 2012/04/07 17:30:55 christos Exp $");
#endif
#endif /* lint */
@@ -218,7 +218,7 @@
{ XX("ledouble"), FILE_LEDOUBLE, FILE_FMT_DOUBLE },
{ XX("leid3"), FILE_LEID3, FILE_FMT_NUM },
{ XX("beid3"), FILE_BEID3, FILE_FMT_NUM },
- { XX("indirect"), FILE_INDIRECT, FILE_FMT_NONE },
+ { XX("indirect"), FILE_INDIRECT, FILE_FMT_NUM },
{ XX_NULL, FILE_INVALID, FILE_FMT_NONE },
# undef XX
# undef XX_NULL
@@ -477,6 +477,9 @@
val += 8 * MULT;
break;
+ case FILE_INDIRECT:
+ break;
+
default:
val = 0;
(void)fprintf(stderr, "Bad type %d\n", m->type);
diff -r 9f01209160a6 -r f78eee451d4b external/bsd/file/dist/src/softmagic.c
--- a/external/bsd/file/dist/src/softmagic.c Sat Apr 07 17:28:44 2012 +0000
+++ b/external/bsd/file/dist/src/softmagic.c Sat Apr 07 17:30:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: softmagic.c,v 1.5 2012/02/22 17:53:51 christos Exp $ */
+/* $NetBSD: softmagic.c,v 1.6 2012/04/07 17:30:56 christos Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
@@ -37,7 +37,7 @@
#if 0
FILE_RCSID("@(#)$File: softmagic.c,v 1.147 2011/11/05 15:44:22 rrt Exp $")
#else
-__RCSID("$NetBSD: softmagic.c,v 1.5 2012/02/22 17:53:51 christos Exp $");
+__RCSID("$NetBSD: softmagic.c,v 1.6 2012/04/07 17:30:56 christos Exp $");
#endif
#endif /* lint */
@@ -1028,6 +1028,8 @@
{
uint32_t offset = ms->offset;
uint32_t count = m->str_range;
+ int rv;
+ char *sbuf, *rbuf;
union VALUETYPE *p = &ms->ms_value;
if (mcopy(ms, p, m->type, m->flag & INDIR, s, offset, nbytes, count) == -1)
@@ -1076,6 +1078,8 @@
(q->hl[3]<<8)|(q->hl[2]));
break;
}
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "indirect offs=%u\n", off);
}
switch (m->in_type) {
case FILE_BYTE:
@@ -1516,6 +1520,8 @@
if (m->flag & INDIROFFADD) {
offset += ms->c.li[cont_level-1].off;
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "indirect +offs=%u\n", offset);
}
if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)
return -1;
@@ -1583,13 +1589,26 @@
break;
case FILE_INDIRECT:
- if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
- file_printf(ms, "%s", m->desc) == -1)
- return -1;
if (nbytes < offset)
return 0;
- return file_softmagic(ms, s + offset, nbytes - offset,
+ sbuf = ms->o.buf;
+ ms->o.buf = NULL;
+ rv = file_softmagic(ms, s + offset, nbytes - offset,
BINTEST, text);
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
+ if (rv == 1) {
+ rbuf = ms->o.buf;
+ ms->o.buf = sbuf;
+ if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
+ file_printf(ms, m->desc, offset) == -1)
+ return -1;
+ if (file_printf(ms, "%s", rbuf) == -1)
+ return -1;
+ free(rbuf);
+ } else
+ ms->o.buf = sbuf;
+ return rv;
case FILE_DEFAULT: /* nothing to check */
default:
Home |
Main Index |
Thread Index |
Old Index