fix #1011789 - update to version 5.19

This commit is contained in:
Jan Kaluza 2014-06-26 13:55:11 +02:00
parent 25dc43a868
commit 3ddc69491b
20 changed files with 81 additions and 741 deletions

View File

@ -1,12 +0,0 @@
diff --git a/src/ascmagic.c b/src/ascmagic.c
index 5a1caac..8d6ca95 100644
--- a/src/ascmagic.c
+++ b/src/ascmagic.c
@@ -211,6 +211,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
case 0:
if (file_printf(ms, ", ") == -1)
goto done;
+ break;
case -1:
goto done;
default:

View File

@ -1,41 +1,56 @@
diff --git a/magic/Magdir/c-lang b/magic/Magdir/c-lang
index 0665627..fdefa8c 100644
--- a/magic/Magdir/c-lang
+++ b/magic/Magdir/c-lang
@@ -6,26 +6,36 @@
# BCPL
0 search/8192 "libhdr" BCPL source text
!:mime text/x-bcpl
+!:strength / 2
0 search/8192 "LIBHDR" BCPL source text
!:mime text/x-bcpl
+!:strength / 2
diff --git a/magic/Magdir/python b/magic/Magdir/python
index d954ee6..52796ba 100644
--- a/magic/Magdir/python
+++ b/magic/Magdir/python
@@ -1,6 +1,6 @@
# C
0 regex \^#include C source text
!:mime text/x-c
+!:strength / 2
0 regex \^char C source text
!:mime text/x-c
+!:strength / 2
0 regex \^double C source text
!:mime text/x-c
+!:strength / 2
0 regex \^extern C source text
!:mime text/x-c
+!:strength / 2
0 regex \^float C source text
!:mime text/x-c
+!:strength / 2
0 regex \^struct C source text
!:mime text/x-c
+!:strength / 2
0 regex \^union C source text
!:mime text/x-c
+!:strength / 2
0 search/8192 main( C source text
!:mime text/x-c
+!:strength / 2
#------------------------------------------------------------------------------
-# $File: python,v 1.25 2014/05/06 16:08:32 christos Exp $
+# $File: python,v 1.22 2013/03/18 12:49:55 christos Exp $
# python: file(1) magic for python
#
# Outlook puts """ too for urgent messages
@@ -37,20 +37,24 @@
# from module.submodule import func1, func2
0 regex \^from\\s+(\\w|\\.)+\\s+import.*$ Python script text executable
!:mime text/x-python
+!:strength + 15
# C++
# The strength of these rules is increased so they beat the C rules above
# def __init__ (self, ...):
0 search/4096 def\ __init__
>&0 search/64 self Python script text executable
!:mime text/x-python
+!:strength + 15
# comments
-#0 search/4096 '''
-#>&0 regex .*'''$ Python script text executable
-#!:mime text/x-python
+0 search/4096 '''
+>&0 regex .*'''$ Python script text executable
+!:mime text/x-python
+!:strength + 15
-#0 search/4096 """
-#>&0 regex .*"""$ Python script text executable
-#!:mime text/x-python
+0 search/4096 """
+>&0 regex .*"""$ Python script text executable
+!:mime text/x-python
+!:strength + 15
# try:
# except: or finally:
@@ -60,8 +64,10 @@
!:mime text/x-python
>&0 search/4096 finally: Python script text executable
!:mime text/x-python
+!:strength + 15
# def name(args, args):
-0 regex \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100}
->&0 regex \ {0,50}\\(([a-zA-Z]|,|\ ){1,255}\\):$ Python script text executable
+0 regex \^(\ |\\t)*def\ +[a-zA-Z]+
+>&0 regex \ *\\(([a-zA-Z]|,|\ )*\\):$ Python script text executable
!:mime text/x-python
+!:strength + 15

View File

@ -1,13 +0,0 @@
diff --git a/src/compress.c b/src/compress.c
index 2b05352..ccb1cfd 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -183,7 +183,7 @@ sread(int fd, void *buf, size_t n, int canbepipe __attribute__ ((unused)))
goto nocheck;
#ifdef FIONREAD
- if ((canbepipe && (ioctl(fd, FIONREAD, &t) == -1)) || (t == 0)) {
+ if (canbepipe && ((ioctl(fd, FIONREAD, &t) == -1) || (t == 0))) {
#ifdef FD_ZERO
for (cnt = 0;; cnt++) {
fd_set check;

View File

@ -1,13 +0,0 @@
diff --git a/magic/Magdir/convex b/magic/Magdir/convex
index 6141a82..4e096b9 100644
--- a/magic/Magdir/convex
+++ b/magic/Magdir/convex
@@ -30,8 +30,6 @@
# The restore program uses these number to determine how the data is
# to be extracted.
#
-24 belong =60011 dump format, 4.1 BSD or earlier
-24 belong =60012 dump format, 4.2 or 4.3 BSD without IDC
24 belong =60013 dump format, 4.2 or 4.3 BSD (IDC compatible)
24 belong =60014 dump format, Convex Storage Manager by-reference dump
#

View File

@ -1,12 +0,0 @@
diff --git a/magic/Magdir/linux b/magic/Magdir/linux
index 8d4c60a..aa8d1aa 100644
--- a/magic/Magdir/linux
+++ b/magic/Magdir/linux
@@ -88,6 +88,7 @@
# From Daniel Novotny <dnovotny@redhat.com>
# swap file for PowerPC
65526 string SWAPSPACE2 Linux/ppc swap file
+16374 string SWAPSPACE2 Linux/ia64 swap file
#
# Linux kernel boot images, from Albert Cahalan <acahalan@cs.uml.edu>
# and others such as Axel Kohlmeyer <akohlmey@rincewind.chemie.uni-ulm.de>

View File

@ -1,32 +0,0 @@
diff --git a/src/magic.c b/src/magic.c
index 5403951..2b61080 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -101,16 +101,21 @@ get_default_magic(void)
if ((home = getenv("HOME")) == NULL)
return MAGIC;
- if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
+ if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
return MAGIC;
- if (stat(hmagicpath, &st) == -1)
- goto out;
- if (S_ISDIR(st.st_mode)) {
+ if (stat(hmagicpath, &st) == -1) {
free(hmagicpath);
- if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
return MAGIC;
- if (access(hmagicpath, R_OK) == -1)
+ if (stat(hmagicpath, &st) == -1)
goto out;
+ if (S_ISDIR(st.st_mode)) {
+ free(hmagicpath);
+ if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+ return MAGIC;
+ if (access(hmagicpath, R_OK) == -1)
+ goto out;
+ }
}
if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)

View File

@ -1,27 +0,0 @@
From ef2329cf71acb59204dd981e2c6cce6c81fe467c Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Mon, 25 Mar 2013 14:06:55 +0000
Subject: [PATCH] limit to 100 repetitions to avoid excessive backtracking
Carsten Wolff
---
magic/Magdir/commands | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/magic/Magdir/commands b/magic/Magdir/commands
index 67c3eee..4a7d8dd 100644
--- a/magic/Magdir/commands
+++ b/magic/Magdir/commands
@@ -49,7 +49,8 @@
!:mime text/x-awk
0 string/wt #!\ /usr/bin/awk awk script text executable
!:mime text/x-awk
-0 regex =^\\s*BEGIN\\s*[{] awk script text
+0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
+!:strength - 12
# AT&T Bell Labs' Plan 9 shell
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
--
1.8.5.5

View File

@ -1,108 +0,0 @@
diff --git a/src/ascmagic.c b/src/ascmagic.c
index 9f1456a..6dda702 100644
--- a/src/ascmagic.c
+++ b/src/ascmagic.c
@@ -147,7 +147,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
== NULL)
goto done;
if ((rv = file_softmagic(ms, utf8_buf,
- (size_t)(utf8_end - utf8_buf), TEXTTEST, text)) == 0)
+ (size_t)(utf8_end - utf8_buf), 0, TEXTTEST, text)) == 0)
rv = -1;
}
diff --git a/src/file.h b/src/file.h
index 2b64399..d1bd332 100644
--- a/src/file.h
+++ b/src/file.h
@@ -438,7 +438,7 @@ protected int file_encoding(struct magic_set *, const unsigned char *, size_t,
unichar **, size_t *, const char **, const char **, const char **);
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
protected int file_softmagic(struct magic_set *, const unsigned char *, size_t,
- int, int);
+ size_t, int, int);
protected int file_apprentice(struct magic_set *, const char *, int);
protected int file_magicfind(struct magic_set *, const char *, struct mlist *);
protected uint64_t file_signextend(struct magic_set *, struct magic *,
diff --git a/src/funcs.c b/src/funcs.c
index 4641c8b..e902c15 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -228,7 +228,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
/* try soft magic tests */
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
- if ((m = file_softmagic(ms, ubuf, nb, BINTEST,
+ if ((m = file_softmagic(ms, ubuf, nb, 0, BINTEST,
looks_text)) != 0) {
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "softmagic %d\n", m);
diff --git a/src/softmagic.c b/src/softmagic.c
index 108d419..d543f87 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -41,6 +41,7 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.165 2013/03/07 02:22:24 christos Exp $")
#include <stdlib.h>
#include <time.h>
+#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) > ((n) - (o)))
private int match(struct magic_set *, struct magic *, uint32_t,
const unsigned char *, size_t, size_t, int, int, int, int, int *, int *,
@@ -69,7 +70,7 @@ private void cvt_64(union VALUETYPE *, const struct magic *);
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
protected int
file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
- int mode, int text)
+ size_t level, int mode, int text)
{
struct mlist *ml;
int rv, printed_something = 0, need_separator = 0;
@@ -79,7 +80,7 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
- text, 0, 0, &printed_something, &need_separator,
+ text, 0, level, &printed_something, &need_separator,
NULL)) != 0)
return rv;
@@ -1707,14 +1708,16 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
break;
case FILE_INDIRECT:
- if (nbytes < offset)
+ if (offset == 0)
+ return 0;
+ if (OFFSET_OOB(nbytes, offset, 0))
return 0;
sbuf = ms->o.buf;
soffset = ms->offset;
ms->o.buf = NULL;
ms->offset = 0;
rv = file_softmagic(ms, s + offset, nbytes - offset,
- BINTEST, text);
+ recursion_level, BINTEST, text);
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
rbuf = ms->o.buf;
@@ -1722,12 +1725,16 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
ms->offset = soffset;
if (rv == 1) {
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
- file_printf(ms, m->desc, offset) == -1)
+ file_printf(ms, m->desc, offset) == -1) {
+ free(rbuf);
return -1;
- if (file_printf(ms, "%s", rbuf) == -1)
+ }
+ if (file_printf(ms, "%s", rbuf) == -1) {
+ free(rbuf);
return -1;
- free(rbuf);
+ }
}
+ free(rbuf);
return rv;
case FILE_USE:

View File

@ -1,125 +0,0 @@
diff --git a/src/softmagic.c b/src/softmagic.c
index d543f87..e84205d 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -1196,7 +1197,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
}
switch (cvt_flip(m->in_type, flip)) {
case FILE_BYTE:
- if (nbytes < (offset + 1))
+ if (OFFSET_OOB(nbytes, offset, 1))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1231,7 +1232,8 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
offset = ~offset;
break;
case FILE_BESHORT:
- if (nbytes < (offset + 2))
+
+ if (OFFSET_OOB(nbytes, offset, 2))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1283,7 +1285,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
offset = ~offset;
break;
case FILE_LESHORT:
- if (nbytes < (offset + 2))
+ if (OFFSET_OOB(nbytes, offset, 2))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1335,7 +1337,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
offset = ~offset;
break;
case FILE_SHORT:
- if (nbytes < (offset + 2))
+ if (OFFSET_OOB(nbytes, offset, 2))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1372,7 +1374,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
break;
case FILE_BELONG:
case FILE_BEID3:
- if (nbytes < (offset + 4))
+ if (OFFSET_OOB(nbytes, offset, 4))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1443,7 +1445,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
break;
case FILE_LELONG:
case FILE_LEID3:
- if (nbytes < (offset + 4))
+ if (OFFSET_OOB(nbytes, offset, 4))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1513,7 +1515,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
offset = ~offset;
break;
case FILE_MELONG:
- if (nbytes < (offset + 4))
+ if (OFFSET_OOB(nbytes, offset, 4))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1583,7 +1585,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
offset = ~offset;
break;
case FILE_LONG:
- if (nbytes < (offset + 4))
+ if (OFFSET_OOB(nbytes, offset, 4))
return 0;
if (off) {
switch (m->in_op & FILE_OPS_MASK) {
@@ -1658,14 +1660,14 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
/* Verify we have enough data to match magic type */
switch (m->type) {
case FILE_BYTE:
- if (nbytes < (offset + 1)) /* should alway be true */
+ if (OFFSET_OOB(nbytes, offset, 1))
return 0;
break;
case FILE_SHORT:
case FILE_BESHORT:
case FILE_LESHORT:
- if (nbytes < (offset + 2))
+ if (OFFSET_OOB(nbytes, offset, 2))
return 0;
break;
@@ -1684,26 +1686,26 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
case FILE_FLOAT:
case FILE_BEFLOAT:
case FILE_LEFLOAT:
- if (nbytes < (offset + 4))
+ if (OFFSET_OOB(nbytes, offset, 4))
return 0;
break;
case FILE_DOUBLE:
case FILE_BEDOUBLE:
case FILE_LEDOUBLE:
- if (nbytes < (offset + 8))
+ if (OFFSET_OOB(nbytes, offset, 8))
return 0;
break;
case FILE_STRING:
case FILE_PSTRING:
case FILE_SEARCH:
- if (nbytes < (offset + m->vallen))
+ if (OFFSET_OOB(nbytes, offset, m->vallen))
return 0;
break;
case FILE_REGEX:
- if (nbytes < offset)
+ if (OFFSET_OOB(nbytes, offset, 0))
return 0;
break;

View File

@ -1,13 +0,0 @@
diff --git a/src/fsmagic.c b/src/fsmagic.c
index bf5f92a..8ad6958 100644
--- a/src/fsmagic.c
+++ b/src/fsmagic.c
@@ -367,7 +367,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
/*NOTREACHED*/
}
- if (!mime && did) {
+ if (!mime && did && ret == 0) {
if (file_printf(ms, " ") == -1)
return -1;
}

View File

@ -1,16 +0,0 @@
diff --git a/magic/Magdir/elf b/magic/Magdir/elf
index 83bdbbf..aa9f539 100644
--- a/magic/Magdir/elf
+++ b/magic/Magdir/elf
@@ -189,9 +189,9 @@
>4 byte 1 32-bit
>4 byte 2 64-bit
>5 byte 0 invalid byte order
->5 byte 1 LSB
+>5 byte 1 LSB
>>0 use elf-le
->5 byte 2 MSB
+>5 byte 2 MSB
>>0 use \^elf-le
# Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed
# like proper ELF, but extracting the string had bad results.

View File

@ -1,38 +0,0 @@
commit c4dda942257181bc75113acce8cfefbadba258d7
Author: Christos Zoulas <christos@zoulas.com>
Date: Wed Jun 26 14:48:31 2013 +0000
asciicize.
diff --git a/magic/Magdir/linux b/magic/Magdir/linux
index 83c816f..634e9b5 100644
--- a/magic/Magdir/linux
+++ b/magic/Magdir/linux
@@ -344,3 +344,27 @@
#>2 regex \(name\ [^)]*\) %s
>20 search/256 (name (name
>>&1 string x %s...)
+
+# Systemd journald files
+# See http://www.freedesktop.org/wiki/Software/systemd/journal-files/.
+# From: Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl>
+
+# check magic
+0 string LPKSHHRH
+# check that state is one of known values
+>16 ubyte&252 0
+# check that each half of three unique id128s is non-zero
+>>24 ubequad >0
+>>>32 ubequad >0
+>>>>40 ubequad >0
+>>>>>48 ubequad >0
+>>>>>>56 ubequad >0
+>>>>>>>64 ubequad >0 Journal file
+!:mime application/octet-stream
+# provide more info
+>>>>>>>>184 leqdate 0 empty
+>>>>>>>>16 ubyte 0 \b, offline
+>>>>>>>>16 ubyte 1 \b, online
+>>>>>>>>16 ubyte 2 \b, archived
+>>>>>>>>8 ulelong&1 1 \b, sealed
+>>>>>>>>12 ulelong&1 1 \b, compressed

View File

@ -1,178 +0,0 @@
From 1198be74dcd8982dfcc9ba5a05e8950376ea74af Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Thu, 2 May 2013 21:58:20 +0000
Subject: [PATCH] PR/248: Multiple magic_loads fail due to global address
re-use. Add a struct to describe the set entries eliminating the global
variable.
---
src/apprentice.c | 58 +++++++++++++++++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/src/apprentice.c b/src/apprentice.c
index 32ba2c0..aca977d 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -80,6 +80,12 @@ struct magic_entry {
uint32_t max_count;
};
+struct magic_entry_set {
+ struct magic_entry *me;
+ uint32_t count;
+ uint32_t max;
+};
+
struct magic_map {
void *p;
size_t len;
@@ -125,7 +131,6 @@ private int apprentice_compile(struct magic_set *, struct magic_map *,
private int parse_apple(struct magic_set *, struct magic_entry *, const char *);
-private size_t maxmagic[MAGIC_SETS] = { 0 };
private size_t magicsize = sizeof(struct magic);
private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
@@ -897,24 +902,24 @@ struct type_tbl_s {
private int
addentry(struct magic_set *ms, struct magic_entry *me,
- struct magic_entry **mentry, uint32_t *mentrycount)
+ struct magic_entry_set *mset)
{
size_t i = me->mp->type == FILE_NAME ? 1 : 0;
- if (mentrycount[i] == maxmagic[i]) {
+ if (mset[i].count == mset[i].max) {
struct magic_entry *mp;
- maxmagic[i] += ALLOC_INCR;
+ mset[i].max += ALLOC_INCR;
if ((mp = CAST(struct magic_entry *,
- realloc(mentry[i], sizeof(*mp) * maxmagic[i]))) ==
+ realloc(mset[i].me, sizeof(*mp) * mset[i].max))) ==
NULL) {
- file_oomem(ms, sizeof(*mp) * maxmagic[i]);
+ file_oomem(ms, sizeof(*mp) * mset[i].max);
return -1;
}
- (void)memset(&mp[mentrycount[i]], 0, sizeof(*mp) *
+ (void)memset(&mp[mset[i].count], 0, sizeof(*mp) *
ALLOC_INCR);
- mentry[i] = mp;
+ mset[i].me = mp;
}
- mentry[i][mentrycount[i]++] = *me;
+ mset[i].me[mset[i].count++] = *me;
memset(me, 0, sizeof(*me));
return 0;
}
@@ -924,7 +929,7 @@ struct type_tbl_s {
*/
private void
load_1(struct magic_set *ms, int action, const char *fn, int *errs,
- struct magic_entry **mentry, uint32_t *mentrycount)
+ struct magic_entry_set *mset)
{
size_t lineno = 0, llen = 0;
char *line = NULL;
@@ -991,7 +996,7 @@ struct type_tbl_s {
case 0:
continue;
case 1:
- (void)addentry(ms, &me, mentry, mentrycount);
+ (void)addentry(ms, &me, mset);
goto again;
default:
(*errs)++;
@@ -1000,7 +1005,7 @@ struct type_tbl_s {
}
}
if (me.mp)
- (void)addentry(ms, &me, mentry, mentrycount);
+ (void)addentry(ms, &me, mset);
free(line);
(void)fclose(f);
}
@@ -1111,19 +1116,21 @@ struct type_tbl_s {
apprentice_load(struct magic_set *ms, const char *fn, int action)
{
int errs = 0;
- struct magic_entry *mentry[MAGIC_SETS] = { NULL };
- uint32_t mentrycount[MAGIC_SETS] = { 0 };
uint32_t i, j;
size_t files = 0, maxfiles = 0;
char **filearr = NULL, *mfn;
struct stat st;
struct magic_map *map;
+ struct magic_entry_set mset[MAGIC_SETS];
DIR *dir;
struct dirent *d;
+ memset(mset, 0, sizeof(mset));
ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */
- if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
+
+ if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL)
+ {
file_oomem(ms, sizeof(*map));
return NULL;
}
@@ -1169,36 +1176,35 @@ struct type_tbl_s {
closedir(dir);
qsort(filearr, files, sizeof(*filearr), cmpstrp);
for (i = 0; i < files; i++) {
- load_1(ms, action, filearr[i], &errs, mentry,
- mentrycount);
+ load_1(ms, action, filearr[i], &errs, mset);
free(filearr[i]);
}
free(filearr);
} else
- load_1(ms, action, fn, &errs, mentry, mentrycount);
+ load_1(ms, action, fn, &errs, mset);
if (errs)
goto out;
for (j = 0; j < MAGIC_SETS; j++) {
/* Set types of tests */
- for (i = 0; i < mentrycount[j]; ) {
- if (mentry[j][i].mp->cont_level != 0) {
+ for (i = 0; i < mset[j].count; ) {
+ if (mset[j].me[i].mp->cont_level != 0) {
i++;
continue;
}
- i = set_text_binary(ms, mentry[j], mentrycount[j], i);
+ i = set_text_binary(ms, mset[j].me, mset[j].count, i);
}
- qsort(mentry[j], mentrycount[j], sizeof(*mentry[j]),
+ qsort(mset[j].me, mset[j].count, sizeof(*mset[j].me),
apprentice_sort);
/*
* Make sure that any level 0 "default" line is last
* (if one exists).
*/
- set_last_default(ms, mentry[j], mentrycount[j]);
+ set_last_default(ms, mset[j].me, mset[j].count);
/* coalesce per file arrays into a single one */
- if (coalesce_entries(ms, mentry[j], mentrycount[j],
+ if (coalesce_entries(ms, mset[j].me, mset[j].count,
&map->magic[j], &map->nmagic[j]) == -1) {
errs++;
goto out;
@@ -1207,7 +1213,7 @@ struct type_tbl_s {
out:
for (j = 0; j < MAGIC_SETS; j++)
- magic_entry_free(mentry[j], mentrycount[j]);
+ magic_entry_free(mset[j].me, mset[j].count);
if (errs) {
for (j = 0; j < MAGIC_SETS; j++) {
--
1.8.4

View File

@ -1,28 +0,0 @@
diff --git a/src/funcs.c b/src/funcs.c
index 7fc0e5c..4641c8b 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -301,7 +301,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
protected int
file_reset(struct magic_set *ms)
{
- if (ms->mlist[0] == NULL) {
+ if (ms->mlist == NULL) {
file_error(ms, 0, "no magic files loaded");
return -1;
}
diff --git a/src/softmagic.c b/src/softmagic.c
index def1e63..108d419 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -73,6 +73,10 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
{
struct mlist *ml;
int rv, printed_something = 0, need_separator = 0;
+
+ if (!ms->mlist[0])
+ return 0;
+
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
text, 0, 0, &printed_something, &need_separator,

View File

@ -1,44 +1,46 @@
diff --git a/magic/Magdir/perl b/magic/Magdir/perl
index 1d7bd31..0118358 100644
index b5b54fb..490dbeb 100644
--- a/magic/Magdir/perl
+++ b/magic/Magdir/perl
@@ -7,22 +7,31 @@
@@ -7,30 +7,39 @@
# Send additions to <perl5-porters@perl.org>
0 search/1/w #!\ /bin/perl Perl script text executable
!:mime text/x-perl
+!:strength + 20
0 search/1 eval\ "exec\ /bin/perl Perl script text
+!:strength + 20
!:mime text/x-perl
0 search/1/w #!\ /usr/bin/perl Perl script text executable
!:mime text/x-perl
+!:strength + 20
+!:strength + 30
0 search/1 eval\ "exec\ /usr/bin/perl Perl script text
!:mime text/x-perl
+!:strength + 20
0 search/1/w #!\ /usr/local/bin/perl Perl script text executable
!:mime text/x-perl
+!:strength + 20
+!:strength + 30
0 search/1 eval\ "exec\ /usr/local/bin/perl Perl script text
!:mime text/x-perl
+!:strength + 20
+!:strength + 30
0 search/1 eval\ '(exit\ $?0)'\ &&\ eval\ 'exec Perl script text
!:mime text/x-perl
+!:strength + 20
+!:strength + 30
0 search/1 #!/usr/bin/env\ perl Perl script text executable
!:mime text/x-perl
+!:strength + 20
+!:strength + 30
0 search/1 #!\ /usr/bin/env\ perl Perl script text executable
!:mime text/x-perl
+!:strength + 25
+!:strength + 30
0 search/1 #!
->0 regex \^#!.*/bin/perl$ Perl script text executable
+>0 regex \^#!.*/bin/perl.*$ Perl script text executable
!:mime text/x-perl
+!:strength + 30
# by Dmitry V. Levin and Alexey Tourbin
# check the first line
@@ -33,7 +42,7 @@
0 search/1 package
>0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *; Perl5 module source text
-!:strength + 10
+!:mime text/x-perl
+!:strength + 45
# not 'p', check other lines
0 search/1 !p
>0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *;
>>0 regex \^1\ *;|\^(use|sub|my)\ .*[(;{=] Perl5 module source text
-!:strength + 10
+!:mime text/x-perl
+!:strength + 45
# Perl POD documents

View File

@ -4,13 +4,13 @@ index 3323593..0f28d7b 100644
+++ b/magic/Magdir/filesystems
@@ -62,7 +62,7 @@
30 search/481 \x55\xAA
# to display x86 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)
# DOS BPB information (70) and after DOS floppy (120) like in previous file version
-!:strength +72
+!:strength +0
# for sector sizes < 512 Bytes
>11 uleshort <512
>>(11.s-2) uleshort 0xAA55 x86 boot sector
>>(11.s-2) uleshort 0xAA55 DOS/MBR boot sector
@@ -1176,7 +1176,7 @@
>11 uleshort&0xf001f 0
>>11 uleshort <32769

View File

@ -1,13 +0,0 @@
diff --git a/magic/Magdir/python b/magic/Magdir/python
index e592803..c786469 100644
--- a/magic/Magdir/python
+++ b/magic/Magdir/python
@@ -59,3 +59,8 @@
!:mime text/x-python
>&0 search/4096 finally: Python script text executable
!:mime text/x-python
+
+# def name(args, args):
+0 regex \^(\ |\\t)*def\ +[a-zA-Z]+
+>&0 regex \ *\\(([a-zA-Z]|,|\ )*\\):$ Python script text executable
+!:mime text/x-python

View File

@ -1,22 +0,0 @@
diff --git a/magic/Magdir/msdos b/magic/Magdir/msdos
index 560d360..83724c5 100644
--- a/magic/Magdir/msdos
+++ b/magic/Magdir/msdos
@@ -815,6 +815,17 @@
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

View File

@ -1,12 +0,0 @@
diff --git a/magic/Magdir/mail.news b/magic/Magdir/mail.news
index 96fa069..fb5e293 100644
--- a/magic/Magdir/mail.news
+++ b/magic/Magdir/mail.news
@@ -34,6 +34,7 @@
# TNEF files...
0 lelong 0x223E9F78 Transport Neutral Encapsulation Format
+!:mime application/vnd.ms-tnef
# From: Kevin Sullivan <ksulliva@psc.edu>
0 string *mbx* MBX mail folder

View File

@ -3,8 +3,8 @@
Summary: A utility for determining file types
Name: file
Version: 5.14
Release: 22%{?dist}
Version: 5.19
Release: 1%{?dist}
License: BSD
Group: Applications/File
Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -12,21 +12,12 @@ Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
Patch0: file-localmagic.patch
# sent upstream - should be included in next upstream release
Patch1: file-5.10-strength.patch
Patch2: file-5.10-sticky-bit.patch
Patch3: file-4.17-rpm-name.patch
Patch4: file-5.04-volume_key.patch
Patch5: file-5.04-man-return-code.patch
Patch6: file-5.04-generic-msdos.patch
Patch7: file-5.14-x86boot.patch
Patch8: file-5.14-perl.patch
Patch9: file-5.14-elfspace.patch
Patch10: file-5.14-bad-fsmagic-space.patch
Patch11: file-5.14-no-magic.patch
Patch12: file-5.14-journald.patch
Patch13: file-5.14-magic_load.patch
Patch14: file-5.14-CVE-2014-1943.patch
Patch15: file-5.14-CVE-2014-2270.patch
Patch16: file-5.14-CVE-2013-7345.patch
URL: http://www.darwinsys.com/file/
Requires: file-libs = %{version}-%{release}
BuildRequires: zlib-devel
@ -89,21 +80,12 @@ file(1) command.
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
# Patches can generate *.orig files, which can't stay in the magic dir,
# otherwise there will be problems with compiling magic file!
@ -204,6 +186,9 @@ cd %{py3dir}
%endif
%changelog
* Wed Jun 25 2014 Jan Kaluza <jkaluza@redhat.com> - 5.19-1
- fix #1011789 - update to version 5.19
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.14-22
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild