From ee63e47572fcf5ab14765d66e23dd06b97e23f7d Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 11 Jan 2013 16:45:23 +0000 Subject: [PATCH] - Warn about continuation levels which are not contiguous when increasing. - Fix broken magic files discovered by that test. --- ChangeLog | 8 ++++++-- magic/Magdir/cafebabe | 10 +++++----- magic/Magdir/digital | 30 +++++++++++++++--------------- magic/Magdir/maple | 4 ++-- magic/Magdir/rpm | 27 ++++++++++----------------- src/apprentice.c | 13 ++++++++++++- 6 files changed, 50 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2bb5e0a0..4cd4f315 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,14 @@ -2013-01-10 11:20 Christos Zoulas +2013-01-10 11:40 Christos Zoulas + + * Warn about inconsistent continuation levels. + +2013-01-10 21:00 Christos Zoulas * Make getline public so that file can link against it. Perhaps it is better to rename it, or hide it differently. Fixes builds on platforms that do not provide it. -2013-01-07 11:20 Christos Zoulas +2013-01-07 16:30 Christos Zoulas * Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document what long, int, short, etc is (Guy Harris) diff --git a/magic/Magdir/cafebabe b/magic/Magdir/cafebabe index 338e9d02..e1f55b0b 100644 --- a/magic/Magdir/cafebabe +++ b/magic/Magdir/cafebabe @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: cafebabe,v 1.10 2012/10/31 16:32:01 christos Exp $ +# $File: cafebabe,v 1.11 2013/01/04 23:27:55 christos Exp $ # Cafe Babes unite! # # Since Java bytecode and Mach-O universal binaries have the same magic number, @@ -30,14 +30,14 @@ >>4 belong 0x0032 (Java 1.6) 0 belong 0xcafed00d JAR compressed with pack200, ->>5 byte x version %d. ->>4 byte x \b%d +>5 byte x version %d. +>4 byte x \b%d !:mime application/x-java-pack200 0 belong 0xcafed00d JAR compressed with pack200, ->>5 byte x version %d. ->>4 byte x \b%d +>5 byte x version %d. +>4 byte x \b%d !:mime application/x-java-pack200 ### JAVA END ### diff --git a/magic/Magdir/digital b/magic/Magdir/digital index 472c877a..d4c85d04 100644 --- a/magic/Magdir/digital +++ b/magic/Magdir/digital @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: digital,v 1.9 2011/04/20 18:55:31 christos Exp $ +# $File: digital,v 1.10 2011/05/03 01:44:17 christos Exp $ # Digital UNIX - Info # 0 string =!\n________64E Alpha archive @@ -8,20 +8,20 @@ # 0 leshort 0603 ->>24 leshort 0410 COFF format alpha pure ->>24 leshort 0413 COFF format alpha demand paged ->>>22 leshort&030000 !020000 executable ->>>22 leshort&020000 !0 dynamically linked ->>>16 lelong !0 not stripped ->>>16 lelong 0 stripped ->>>27 byte x - version %d ->>>26 byte x \b.%d ->>>28 byte x \b-%d ->>24 leshort 0407 COFF format alpha object ->>>22 leshort&030000 020000 shared library ->>>27 byte x - version %d ->>>26 byte x \b.%d ->>>28 byte x \b-%d +>24 leshort 0410 COFF format alpha pure +>24 leshort 0413 COFF format alpha demand paged +>>22 leshort&030000 !020000 executable +>>22 leshort&020000 !0 dynamically linked +>>16 lelong !0 not stripped +>>16 lelong 0 stripped +>>27 byte x - version %d +>>26 byte x \b.%d +>>28 byte x \b-%d +>24 leshort 0407 COFF format alpha object +>>22 leshort&030000 020000 shared library +>>27 byte x - version %d +>>26 byte x \b.%d +>>28 byte x \b-%d # Basic recognition of Digital UNIX core dumps - Mike Bremford # diff --git a/magic/Magdir/maple b/magic/Magdir/maple index 5c076ef9..d72689a7 100644 --- a/magic/Magdir/maple +++ b/magic/Magdir/maple @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File$ +# $File: maple,v 1.6 2009/09/19 16:28:10 christos Exp $ # maple: file(1) magic for maple files # "H. Nanosecond" # Maple V release 4, a multi-purpose math program @@ -33,7 +33,7 @@ # that is {VERSION major_version miunor_version computer_type version_string} 0 string {VERSION\ Maple worksheet >9 string >\0 version %.1s. ->>>11 string >\0 %.1s +>>11 string >\0 %.1s # .mps 0 string \0\0\001$ Maple something diff --git a/magic/Magdir/rpm b/magic/Magdir/rpm index 5eeb006c..fa336c07 100644 --- a/magic/Magdir/rpm +++ b/magic/Magdir/rpm @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: rpm,v 1.10 2010/09/20 19:19:17 rrt Exp $ +# $File: rpm,v 1.11 2011/06/14 12:47:41 christos Exp $ # # RPM: file(1) magic for Red Hat Packages Erik Troan (ewt@redhat.com) # @@ -31,22 +31,15 @@ >>8 beshort 255 noarch #delta RPM Daniel Novotny (dnovotny@redhat.com) -0 string drpm Delta RPM +0 string drpm Delta RPM !:mime application/x-rpm >12 string x %s - ->>>8 beshort 11 MIPSel ->>>8 beshort 12 ARM ->>>8 beshort 13 MiNT ->>>8 beshort 14 S/390 ->>>8 beshort 15 S/390x ->>>8 beshort 16 PowerPC64 ->>>8 beshort 17 SuperH ->>>8 beshort 18 Xtensa +>>8 beshort 11 MIPSel +>>8 beshort 12 ARM +>>8 beshort 13 MiNT +>>8 beshort 14 S/390 +>>8 beshort 15 S/390x +>>8 beshort 16 PowerPC64 +>>8 beshort 17 SuperH +>>8 beshort 18 Xtensa >>10 string x %s - -# Type: Delta RPM -# From: Daniel Novotny (dnovotny@redhat.com) -0 string drpm Delta RPM -!:mime application/x-rpm ->12 string x %s diff --git a/src/apprentice.c b/src/apprentice.c index ff717846..93bde921 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.187 2013/01/09 13:03:41 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.188 2013/01/09 15:36:55 christos Exp $") #endif /* lint */ #include "magic.h" @@ -1461,6 +1461,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, char *t; int op; uint32_t cont_level; + int32_t diff; cont_level = 0; @@ -1482,6 +1483,16 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line, file_magerror(ms, "No current entry for continuation"); return -1; } + if (me->cont_count == 0) { + file_magerror(ms, "Continuations present with 0 count"); + return -1; + } + m = &me->mp[me->cont_count - 1]; + diff = (int32_t)cont_level - (int32_t)m->cont_level; + if (diff > 1) + file_magwarn(ms, "New continuation level %u is more " + "than one larger than current level %u", cont_level, + m->cont_level); if (me->cont_count == me->max_count) { struct magic *nm; size_t cnt = me->max_count + ALLOC_CHUNK; -- 2.40.0