Skip to content

Commit

Permalink
- Warn about continuation levels which are not contiguous when increa…
Browse files Browse the repository at this point in the history
…sing.

- Fix broken magic files discovered by that test.
  • Loading branch information
zoulasc committed Jan 11, 2013
1 parent 3ffb3db commit ee63e47
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 42 deletions.
8 changes: 6 additions & 2 deletions ChangeLog
@@ -1,10 +1,14 @@
2013-01-10 11:20 Christos Zoulas <christos@zoulas.com>
2013-01-10 11:40 Christos Zoulas <christos@zoulas.com>

* Warn about inconsistent continuation levels.

2013-01-10 21:00 Christos Zoulas <christos@zoulas.com>

* 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 <christos@zoulas.com>
2013-01-07 16:30 Christos Zoulas <christos@zoulas.com>

* Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document
what long, int, short, etc is (Guy Harris)
Expand Down
10 changes: 5 additions & 5 deletions 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,
Expand Down Expand Up @@ -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 ###
Expand Down
30 changes: 15 additions & 15 deletions magic/Magdir/digital
@@ -1,27 +1,27 @@

#------------------------------------------------------------------------------
# $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 =!<arch>\n________64E Alpha archive
>22 string X -- out of date
#

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 <mike@opac.bl.uk>
#
Expand Down
4 changes: 2 additions & 2 deletions 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" <aldomel@ix.netcom.com>
# Maple V release 4, a multi-purpose math program
Expand Down Expand Up @@ -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
Expand Down
27 changes: 10 additions & 17 deletions 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)
#
Expand Down Expand Up @@ -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
13 changes: 12 additions & 1 deletion src/apprentice.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit ee63e47

Please sign in to comment.