commit
664e66deb6
@ -0,0 +1 @@
|
||||
a5a8941a8e4c436fe22933db6a71c5161c3fb10b SOURCES/file-5.39.tar.gz
|
@ -0,0 +1 @@
|
||||
SOURCES/file-5.39.tar.gz
|
@ -0,0 +1,12 @@
|
||||
diff --git a/magic/Magdir/rpm b/magic/Magdir/rpm
|
||||
index 9a795f8..31db083 100644
|
||||
--- a/magic/Magdir/rpm
|
||||
+++ b/magic/Magdir/rpm
|
||||
@@ -29,6 +29,7 @@
|
||||
>>8 beshort 17 SuperH
|
||||
>>8 beshort 18 Xtensa
|
||||
>>8 beshort 255 noarch
|
||||
+>>10 string x %s
|
||||
|
||||
#delta RPM Daniel Novotny (dnovotny@redhat.com)
|
||||
0 string drpm Delta RPM
|
@ -0,0 +1,10 @@
|
||||
diff --git a/magic/Magdir/securitycerts b/magic/Magdir/securitycerts
|
||||
index 8785dd8..1c340be 100644
|
||||
--- a/magic/Magdir/securitycerts
|
||||
+++ b/magic/Magdir/securitycerts
|
||||
@@ -4,3 +4,5 @@
|
||||
0 search/1 -----BEGIN\ CERTIFICATE------ RFC1421 Security Certificate text
|
||||
0 search/1 -----BEGIN\ NEW\ CERTIFICATE RFC1421 Security Certificate Signing Request text
|
||||
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
|
||||
+
|
||||
+0 string \0volume_key volume_key escrow packet
|
@ -0,0 +1,45 @@
|
||||
diff --git a/src/compress.c b/src/compress.c
|
||||
index ba1e3d7..6846d66 100644
|
||||
--- a/src/compress.c
|
||||
+++ b/src/compress.c
|
||||
@@ -932,23 +932,23 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
|
||||
rv = OKDATA;
|
||||
r = sread(fdp[STDOUT_FILENO][0], *newch, bytes_max, 0);
|
||||
if (r <= 0) {
|
||||
- DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0],
|
||||
- r != -1 ? strerror(errno) : "no data");
|
||||
-
|
||||
- rv = ERRDATA;
|
||||
- if (r == 0 &&
|
||||
- (r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0)
|
||||
- {
|
||||
- r = filter_error(*newch, r);
|
||||
- goto ok;
|
||||
- }
|
||||
- free(*newch);
|
||||
- if (r == 0)
|
||||
- rv = makeerror(newch, n, "Read failed, %s",
|
||||
- strerror(errno));
|
||||
- else
|
||||
- rv = makeerror(newch, n, "No data");
|
||||
- goto err;
|
||||
+ if (r < 0) {
|
||||
+ rv = ERRDATA;
|
||||
+ DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0],
|
||||
+ strerror(errno));
|
||||
+ goto err;
|
||||
+ } else if ((r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0){
|
||||
+ rv = ERRDATA;
|
||||
+ r = filter_error(*newch, r);
|
||||
+ goto ok;
|
||||
+ }
|
||||
+ if (r == 0)
|
||||
+ goto ok;
|
||||
+ free(*newch);
|
||||
+ rv = ERRDATA;
|
||||
+ rv = makeerror(newch, n, "Read stderr failed, %s",
|
||||
+ strerror(errno));
|
||||
+ goto err;
|
||||
}
|
||||
ok:
|
||||
*n = r;
|
@ -0,0 +1,201 @@
|
||||
diff --git a/ChangeLog b/ChangeLog
|
||||
index d46caaa0d..41d6e99d9 100644
|
||||
--- a/ChangeLog
|
||||
+++ b/ChangeLog
|
||||
@@ -1,3 +1,8 @@
|
||||
+2020-12-08 16:24 Christos Zoulas <christos@zoulas.com>
|
||||
+
|
||||
+ * fix multithreaded decompression file descriptor issue
|
||||
+ by using close-on-exec (Denys Vlasenko)
|
||||
+
|
||||
2020-06-14 20:02 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* release 5.39
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 64c9f42e3..521dc12db 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -166,7 +166,7 @@ else
|
||||
fi])
|
||||
|
||||
dnl Checks for functions
|
||||
-AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem)
|
||||
+AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2)
|
||||
|
||||
dnl Provide implementation of some required functions if necessary
|
||||
AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
|
||||
diff --git a/src/compress.c b/src/compress.c
|
||||
index cbc2ce19b..9f65e4fa1 100644
|
||||
--- a/src/compress.c
|
||||
+++ b/src/compress.c
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
-FILE_RCSID("@(#)$File: compress.c,v 1.127 2020/05/31 00:11:06 christos Exp $")
|
||||
+FILE_RCSID("@(#)$File: compress.c,v 1.129 2020/12/08 21:26:00 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include "magic.h"
|
||||
@@ -844,8 +844,23 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
|
||||
for (i = 0; i < __arraycount(fdp); i++)
|
||||
fdp[i][0] = fdp[i][1] = -1;
|
||||
|
||||
- if ((fd == -1 && pipe(fdp[STDIN_FILENO]) == -1) ||
|
||||
- pipe(fdp[STDOUT_FILENO]) == -1 || pipe(fdp[STDERR_FILENO]) == -1) {
|
||||
+ /*
|
||||
+ * There are multithreaded users who run magic_file()
|
||||
+ * from dozens of threads. If two parallel magic_file() calls
|
||||
+ * analyze two large compressed files, both will spawn
|
||||
+ * an uncompressing child here, which writes out uncompressed data.
|
||||
+ * We read some portion, then close the pipe, then waitpid() the child.
|
||||
+ * If uncompressed data is larger, child shound get EPIPE and exit.
|
||||
+ * However, with *parallel* calls OTHER child may unintentionally
|
||||
+ * inherit pipe fds, thus keeping pipe open and making writes in
|
||||
+ * our child block instead of failing with EPIPE!
|
||||
+ * (For the bug to occur, two threads must mutually inherit their pipes,
|
||||
+ * and both must have large outputs. Thus it happens not that often).
|
||||
+ * To avoid this, be sure to create pipes with O_CLOEXEC.
|
||||
+ */
|
||||
+ if ((fd == -1 && file_pipe_closexec(fdp[STDIN_FILENO]) == -1) ||
|
||||
+ file_pipe_closexec(fdp[STDOUT_FILENO]) == -1 ||
|
||||
+ file_pipe_closexec(fdp[STDERR_FILENO]) == -1) {
|
||||
closep(fdp[STDIN_FILENO]);
|
||||
closep(fdp[STDOUT_FILENO]);
|
||||
return makeerror(newch, n, "Cannot create pipe, %s",
|
||||
@@ -876,16 +891,20 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
|
||||
if (fdp[STDIN_FILENO][1] > 2)
|
||||
(void) close(fdp[STDIN_FILENO][1]);
|
||||
}
|
||||
+ file_clear_closexec(STDIN_FILENO);
|
||||
+
|
||||
///FIXME: if one of the fdp[i][j] is 0 or 1, this can bomb spectacularly
|
||||
if (copydesc(STDOUT_FILENO, fdp[STDOUT_FILENO][1]))
|
||||
(void) close(fdp[STDOUT_FILENO][1]);
|
||||
if (fdp[STDOUT_FILENO][0] > 2)
|
||||
(void) close(fdp[STDOUT_FILENO][0]);
|
||||
+ file_clear_closexec(STDOUT_FILENO);
|
||||
|
||||
if (copydesc(STDERR_FILENO, fdp[STDERR_FILENO][1]))
|
||||
(void) close(fdp[STDERR_FILENO][1]);
|
||||
if (fdp[STDERR_FILENO][0] > 2)
|
||||
(void) close(fdp[STDERR_FILENO][0]);
|
||||
+ file_clear_closexec(STDERR_FILENO);
|
||||
|
||||
(void)execvp(compr[method].argv[0],
|
||||
RCAST(char *const *, RCAST(intptr_t, compr[method].argv)));
|
||||
diff --git a/src/file.h b/src/file.h
|
||||
index f00e8010b..6c3900479 100644
|
||||
--- a/src/file.h
|
||||
+++ b/src/file.h
|
||||
@@ -27,7 +27,7 @@
|
||||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
- * @(#)$File: file.h,v 1.220 2020/06/08 17:38:27 christos Exp $
|
||||
+ * @(#)$File: file.h,v 1.223 2020/12/08 21:26:00 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
@@ -143,6 +143,14 @@
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
+#ifndef O_CLOEXEC
|
||||
+# define O_CLOEXEC 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef FD_CLOEXEC
|
||||
+# define FD_CLOEXEC 1
|
||||
+#endif
|
||||
+
|
||||
#define FILE_BADSIZE CAST(size_t, ~0ul)
|
||||
#define MAXDESC 64 /* max len of text description/MIME type */
|
||||
#define MAXMIME 80 /* max len of text MIME type */
|
||||
@@ -540,6 +548,8 @@ protected char * file_printable(char *, size_t, const char *, size_t);
|
||||
protected int file_os2_apptype(struct magic_set *, const char *, const void *,
|
||||
size_t);
|
||||
#endif /* __EMX__ */
|
||||
+protected int file_pipe_closexec(int *);
|
||||
+protected int file_clear_closexec(int);
|
||||
|
||||
protected void buffer_init(struct buffer *, int, const struct stat *,
|
||||
const void *, size_t);
|
||||
diff --git a/src/funcs.c b/src/funcs.c
|
||||
index ecbfa28c5..bcf9ddaae 100644
|
||||
--- a/src/funcs.c
|
||||
+++ b/src/funcs.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
-FILE_RCSID("@(#)$File: funcs.c,v 1.115 2020/02/20 15:50:20 christos Exp $")
|
||||
+FILE_RCSID("@(#)$File: funcs.c,v 1.118 2020/12/08 21:26:00 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@@ -36,6 +36,9 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.117 2020/06/25 16:52:48 christos Exp $")
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
+#ifdef HAVE_UNISTD_H
|
||||
+#include <unistd.h> /* for pipe2() */
|
||||
+#endif
|
||||
#if defined(HAVE_WCHAR_H)
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
@@ -784,3 +787,22 @@ file_print_guid(char *str, size_t len, const uint64_t *guid)
|
||||
g->data4[2], g->data4[3], g->data4[4], g->data4[5],
|
||||
g->data4[6], g->data4[7]);
|
||||
}
|
||||
+
|
||||
+protected int
|
||||
+file_pipe_closexec(int *fds)
|
||||
+{
|
||||
+#ifdef HAVE_PIPE2
|
||||
+ return pipe2(fds, O_CLOEXEC);
|
||||
+#else
|
||||
+ if (pipe(fds) == -1)
|
||||
+ return -1;
|
||||
+ (void)fcntl(fds[0], F_SETFD, FD_CLOEXEC);
|
||||
+ (void)fcntl(fds[1], F_SETFD, FD_CLOEXEC);
|
||||
+ return 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+protected int
|
||||
+file_clear_closexec(int fd) {
|
||||
+ return fcntl(fd, F_SETFD, 0);
|
||||
+}
|
||||
diff --git a/src/magic.c b/src/magic.c
|
||||
index 17a7077d8..89f4e16c0 100644
|
||||
--- a/src/magic.c
|
||||
+++ b/src/magic.c
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
-FILE_RCSID("@(#)$File: magic.c,v 1.112 2020/06/08 19:44:10 christos Exp $")
|
||||
+FILE_RCSID("@(#)$File: magic.c,v 1.113 2020/12/08 21:26:00 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@@ -436,7 +436,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
||||
_setmode(STDIN_FILENO, O_BINARY);
|
||||
#endif
|
||||
if (inname != NULL) {
|
||||
- int flags = O_RDONLY|O_BINARY|O_NONBLOCK;
|
||||
+ int flags = O_RDONLY|O_BINARY|O_NONBLOCK|O_CLOEXEC;
|
||||
errno = 0;
|
||||
if ((fd = open(inname, flags)) < 0) {
|
||||
okstat = stat(inname, &sb) == 0;
|
||||
@@ -460,6 +460,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
||||
rv = 0;
|
||||
goto done;
|
||||
}
|
||||
+#if O_CLOEXEC == 0
|
||||
+ (void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
+#endif
|
||||
}
|
||||
|
||||
if (fd != -1) {
|
@ -0,0 +1,377 @@
|
||||
diff --git a/src/apprentice.c b/src/apprentice.c
|
||||
index b609dd1..21eac1e 100644
|
||||
--- a/src/apprentice.c
|
||||
+++ b/src/apprentice.c
|
||||
@@ -423,7 +423,15 @@ add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx)
|
||||
ml->map = idx == 0 ? map : NULL;
|
||||
ml->magic = map->magic[idx];
|
||||
ml->nmagic = map->nmagic[idx];
|
||||
-
|
||||
+ if (ml->nmagic) {
|
||||
+ ml->magic_rxcomp = CAST(file_regex_t **,
|
||||
+ calloc(ml->nmagic, sizeof(*ml->magic_rxcomp)));
|
||||
+ if (ml->magic_rxcomp == NULL) {
|
||||
+ free(ml);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else
|
||||
+ ml->magic_rxcomp = NULL;
|
||||
mlp->prev->next = ml;
|
||||
ml->prev = mlp->prev;
|
||||
ml->next = mlp;
|
||||
@@ -607,8 +615,19 @@ mlist_free_all(struct magic_set *ms)
|
||||
private void
|
||||
mlist_free_one(struct mlist *ml)
|
||||
{
|
||||
+ size_t i;
|
||||
+
|
||||
if (ml->map)
|
||||
apprentice_unmap(CAST(struct magic_map *, ml->map));
|
||||
+
|
||||
+ for (i = 0; i < ml->nmagic; ++i) {
|
||||
+ if (ml->magic_rxcomp[i]) {
|
||||
+ file_regfree(ml->magic_rxcomp[i]);
|
||||
+ free(ml->magic_rxcomp[i]);
|
||||
+ }
|
||||
+ }
|
||||
+ free(ml->magic_rxcomp);
|
||||
+ ml->magic_rxcomp = NULL;
|
||||
free(ml);
|
||||
}
|
||||
|
||||
@@ -3492,16 +3511,16 @@ file_magicfind(struct magic_set *ms, const char *name, struct mlist *v)
|
||||
|
||||
for (ml = mlist->next; ml != mlist; ml = ml->next) {
|
||||
struct magic *ma = ml->magic;
|
||||
- uint32_t nma = ml->nmagic;
|
||||
- for (i = 0; i < nma; i++) {
|
||||
+ for (i = 0; i < ml->nmagic; i++) {
|
||||
if (ma[i].type != FILE_NAME)
|
||||
continue;
|
||||
if (strcmp(ma[i].value.s, name) == 0) {
|
||||
v->magic = &ma[i];
|
||||
- for (j = i + 1; j < nma; j++)
|
||||
+ for (j = i + 1; j < ml->nmagic; j++)
|
||||
if (ma[j].cont_level == 0)
|
||||
break;
|
||||
v->nmagic = j - i;
|
||||
+ v->magic_rxcomp = ml->magic_rxcomp;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
diff --git a/src/file.h b/src/file.h
|
||||
index 48f4b69..c0b5a7c 100644
|
||||
--- a/src/file.h
|
||||
+++ b/src/file.h
|
||||
@@ -88,6 +88,10 @@
|
||||
/* Do this here and now, because struct stat gets re-defined on solaris */
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
+#include <locale.h>
|
||||
+#if defined(HAVE_XLOCALE_H)
|
||||
+#include <xlocale.h>
|
||||
+#endif
|
||||
|
||||
#define ENABLE_CONDITIONALS
|
||||
|
||||
@@ -167,6 +171,19 @@
|
||||
#define FILE_COMPILE 2
|
||||
#define FILE_LIST 3
|
||||
|
||||
+typedef struct {
|
||||
+ const char *pat;
|
||||
+#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
|
||||
+#define USE_C_LOCALE
|
||||
+ locale_t old_lc_ctype;
|
||||
+ locale_t c_lc_ctype;
|
||||
+#else
|
||||
+ char *old_lc_ctype;
|
||||
+#endif
|
||||
+ int rc;
|
||||
+ regex_t rx;
|
||||
+} file_regex_t;
|
||||
+
|
||||
struct buffer {
|
||||
int fd;
|
||||
struct stat st;
|
||||
@@ -394,7 +411,8 @@ struct magic {
|
||||
/* list of magic entries */
|
||||
struct mlist {
|
||||
struct magic *magic; /* array of magic entries */
|
||||
- uint32_t nmagic; /* number of entries in array */
|
||||
+ file_regex_t **magic_rxcomp; /* array of compiled regexps */
|
||||
+ size_t nmagic; /* number of entries in array */
|
||||
void *map; /* internal resources used by entry */
|
||||
struct mlist *next, *prev;
|
||||
};
|
||||
@@ -554,23 +572,7 @@ protected void buffer_init(struct buffer *, int, const struct stat *,
|
||||
protected void buffer_fini(struct buffer *);
|
||||
protected int buffer_fill(const struct buffer *);
|
||||
|
||||
-#include <locale.h>
|
||||
-#if defined(HAVE_XLOCALE_H)
|
||||
-#include <xlocale.h>
|
||||
-#endif
|
||||
|
||||
-typedef struct {
|
||||
- const char *pat;
|
||||
-#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
|
||||
-#define USE_C_LOCALE
|
||||
- locale_t old_lc_ctype;
|
||||
- locale_t c_lc_ctype;
|
||||
-#else
|
||||
- char *old_lc_ctype;
|
||||
-#endif
|
||||
- int rc;
|
||||
- regex_t rx;
|
||||
-} file_regex_t;
|
||||
|
||||
protected int file_regcomp(file_regex_t *, const char *, int);
|
||||
protected int file_regexec(file_regex_t *, const char *, size_t, regmatch_t *,
|
||||
diff --git a/src/softmagic.c b/src/softmagic.c
|
||||
index 95061e5..834dfe3 100644
|
||||
--- a/src/softmagic.c
|
||||
+++ b/src/softmagic.c
|
||||
@@ -43,7 +43,7 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.299 2020/06/07 21:58:01 christos Exp $")
|
||||
#include <time.h>
|
||||
#include "der.h"
|
||||
|
||||
-private int match(struct magic_set *, struct magic *, uint32_t,
|
||||
+private int match(struct magic_set *, struct magic *, file_regex_t **, uint32_t,
|
||||
const struct buffer *, size_t, int, int, int, uint16_t *,
|
||||
uint16_t *, int *, int *, int *, int *);
|
||||
private int mget(struct magic_set *, struct magic *, const struct buffer *,
|
||||
@@ -52,7 +52,7 @@ private int mget(struct magic_set *, struct magic *, const struct buffer *,
|
||||
uint16_t *, int *, int *, int *, int *);
|
||||
private int msetoffset(struct magic_set *, struct magic *, struct buffer *,
|
||||
const struct buffer *, size_t, unsigned int);
|
||||
-private int magiccheck(struct magic_set *, struct magic *);
|
||||
+private int magiccheck(struct magic_set *, struct magic *, file_regex_t **);
|
||||
private int32_t mprint(struct magic_set *, struct magic *);
|
||||
private int moffset(struct magic_set *, struct magic *, const struct buffer *,
|
||||
int32_t *);
|
||||
@@ -131,8 +131,8 @@ file_softmagic(struct magic_set *ms, const struct buffer *b,
|
||||
}
|
||||
|
||||
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
|
||||
- if ((rv = match(ms, ml->magic, ml->nmagic, b, 0, mode,
|
||||
- text, 0, indir_count, name_count,
|
||||
+ if ((rv = match(ms, ml->magic, ml->magic_rxcomp, ml->nmagic, b,
|
||||
+ 0, mode, text, 0, indir_count, name_count,
|
||||
&printed_something, &need_separator, NULL, NULL)) != 0)
|
||||
return rv;
|
||||
|
||||
@@ -191,8 +191,8 @@ file_fmtcheck(struct magic_set *ms, const char *desc, const char *def,
|
||||
* so that higher-level continuations are processed.
|
||||
*/
|
||||
private int
|
||||
-match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
- const struct buffer *b, size_t offset, int mode, int text,
|
||||
+match(struct magic_set *ms, struct magic *magic, file_regex_t **magic_rxcomp,
|
||||
+ uint32_t nmagic, const struct buffer *b, size_t offset, int mode, int text,
|
||||
int flip, uint16_t *indir_count, uint16_t *name_count,
|
||||
int *printed_something, int *need_separator, int *returnval,
|
||||
int *found_match)
|
||||
@@ -220,6 +220,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
for (magindex = 0; magindex < nmagic; magindex++) {
|
||||
int flush = 0;
|
||||
struct magic *m = &magic[magindex];
|
||||
+ file_regex_t **m_rxcomp = &magic_rxcomp[magindex];
|
||||
|
||||
if (m->type != FILE_NAME)
|
||||
if ((IS_STRING(m->type) &&
|
||||
@@ -257,7 +258,7 @@ flush:
|
||||
*returnval = 1;
|
||||
}
|
||||
|
||||
- switch (magiccheck(ms, m)) {
|
||||
+ switch (magiccheck(ms, m, m_rxcomp)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
@@ -317,6 +318,7 @@ flush:
|
||||
while (magindex + 1 < nmagic &&
|
||||
magic[magindex + 1].cont_level != 0) {
|
||||
m = &magic[++magindex];
|
||||
+ m_rxcomp = &magic_rxcomp[magindex];
|
||||
ms->line = m->lineno; /* for messages */
|
||||
|
||||
if (cont_level < m->cont_level)
|
||||
@@ -370,7 +372,7 @@ flush:
|
||||
break;
|
||||
}
|
||||
|
||||
- switch (flush ? 1 : magiccheck(ms, m)) {
|
||||
+ switch (flush ? 1 : magiccheck(ms, m, m_rxcomp)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
@@ -1880,8 +1882,8 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
|
||||
oneed_separator = *need_separator;
|
||||
if (m->flag & NOSPACE)
|
||||
*need_separator = 0;
|
||||
- rv = match(ms, ml.magic, ml.nmagic, b, offset + o,
|
||||
- mode, text, flip, indir_count, name_count,
|
||||
+ rv = match(ms, ml.magic, ml.magic_rxcomp, ml.nmagic, b,
|
||||
+ offset + o, mode, text, flip, indir_count, name_count,
|
||||
printed_something, need_separator, returnval, found_match);
|
||||
(*name_count)--;
|
||||
if (rv != 1)
|
||||
@@ -1989,8 +1991,31 @@ file_strncmp16(const char *a, const char *b, size_t len, size_t maxlen,
|
||||
return file_strncmp(a, b, len, maxlen, flags);
|
||||
}
|
||||
|
||||
+private file_regex_t *
|
||||
+alloc_regex(struct magic_set *ms, struct magic *m)
|
||||
+{
|
||||
+ int rc;
|
||||
+ file_regex_t *rx = CAST(file_regex_t *, malloc(sizeof(*rx)));
|
||||
+
|
||||
+ if (rx == NULL) {
|
||||
+ file_error(ms, errno, "can't allocate %" SIZE_T_FORMAT
|
||||
+ "u bytes", sizeof(*rx));
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ rc = file_regcomp(rx, m->value.s, REG_EXTENDED | REG_NEWLINE |
|
||||
+ ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
|
||||
+ if (rc == 0)
|
||||
+ return rx;
|
||||
+
|
||||
+ file_regerror(rx, rc, ms);
|
||||
+ file_regfree(rx);
|
||||
+ free(rx);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
private int
|
||||
-magiccheck(struct magic_set *ms, struct magic *m)
|
||||
+magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache)
|
||||
{
|
||||
uint64_t l = m->value.q;
|
||||
uint64_t v;
|
||||
@@ -2068,8 +2093,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
break;
|
||||
|
||||
default:
|
||||
- file_magerror(ms, "cannot happen with float: invalid relation `%c'",
|
||||
- m->reln);
|
||||
+ file_magerror(ms, "cannot happen with float: "
|
||||
+ "invalid relation `%c'", m->reln);
|
||||
return -1;
|
||||
}
|
||||
return matched;
|
||||
@@ -2101,7 +2126,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
break;
|
||||
|
||||
default:
|
||||
- file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
|
||||
+ file_magerror(ms, "cannot happen with double: "
|
||||
+ "invalid relation `%c'", m->reln);
|
||||
return -1;
|
||||
}
|
||||
return matched;
|
||||
@@ -2169,62 +2195,57 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
}
|
||||
case FILE_REGEX: {
|
||||
int rc;
|
||||
- file_regex_t rx;
|
||||
+ file_regex_t *rx = *m_cache;
|
||||
const char *search;
|
||||
+ regmatch_t pmatch;
|
||||
+ size_t slen = ms->search.s_len;
|
||||
+ char *copy;
|
||||
|
||||
if (ms->search.s == NULL)
|
||||
return 0;
|
||||
|
||||
+ if (rx == NULL) {
|
||||
+ rx = *m_cache = alloc_regex(ms, m);
|
||||
+ if (rx == NULL)
|
||||
+ return -1;
|
||||
+ }
|
||||
l = 0;
|
||||
- rc = file_regcomp(&rx, m->value.s,
|
||||
- REG_EXTENDED|REG_NEWLINE|
|
||||
- ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
|
||||
- if (rc) {
|
||||
- file_regerror(&rx, rc, ms);
|
||||
- v = CAST(uint64_t, -1);
|
||||
+ if (slen != 0) {
|
||||
+ copy = CAST(char *, malloc(slen));
|
||||
+ if (copy == NULL) {
|
||||
+ file_error(ms, errno,
|
||||
+ "can't allocate %" SIZE_T_FORMAT "u bytes",
|
||||
+ slen);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ memcpy(copy, ms->search.s, slen);
|
||||
+ copy[--slen] = '\0';
|
||||
+ search = copy;
|
||||
} else {
|
||||
- regmatch_t pmatch;
|
||||
- size_t slen = ms->search.s_len;
|
||||
- char *copy;
|
||||
- if (slen != 0) {
|
||||
- copy = CAST(char *, malloc(slen));
|
||||
- if (copy == NULL) {
|
||||
- file_regfree(&rx);
|
||||
- file_error(ms, errno,
|
||||
- "can't allocate %" SIZE_T_FORMAT "u bytes",
|
||||
- slen);
|
||||
- return -1;
|
||||
- }
|
||||
- memcpy(copy, ms->search.s, slen);
|
||||
- copy[--slen] = '\0';
|
||||
- search = copy;
|
||||
- } else {
|
||||
- search = CCAST(char *, "");
|
||||
- copy = NULL;
|
||||
- }
|
||||
- rc = file_regexec(&rx, RCAST(const char *, search),
|
||||
- 1, &pmatch, 0);
|
||||
- free(copy);
|
||||
- switch (rc) {
|
||||
- case 0:
|
||||
- ms->search.s += CAST(int, pmatch.rm_so);
|
||||
- ms->search.offset += CAST(size_t, pmatch.rm_so);
|
||||
- ms->search.rm_len = CAST(size_t,
|
||||
- pmatch.rm_eo - pmatch.rm_so);
|
||||
- v = 0;
|
||||
- break;
|
||||
+ search = CCAST(char *, "");
|
||||
+ copy = NULL;
|
||||
+ }
|
||||
+ rc = file_regexec(rx, RCAST(const char *, search),
|
||||
+ 1, &pmatch, 0);
|
||||
+ free(copy);
|
||||
+ switch (rc) {
|
||||
+ case 0:
|
||||
+ ms->search.s += CAST(int, pmatch.rm_so);
|
||||
+ ms->search.offset += CAST(size_t, pmatch.rm_so);
|
||||
+ ms->search.rm_len = CAST(size_t,
|
||||
+ pmatch.rm_eo - pmatch.rm_so);
|
||||
+ v = 0;
|
||||
+ break;
|
||||
|
||||
- case REG_NOMATCH:
|
||||
- v = 1;
|
||||
- break;
|
||||
+ case REG_NOMATCH:
|
||||
+ v = 1;
|
||||
+ break;
|
||||
|
||||
- default:
|
||||
- file_regerror(&rx, rc, ms);
|
||||
- v = CAST(uint64_t, -1);
|
||||
- break;
|
||||
- }
|
||||
+ default:
|
||||
+ file_regerror(rx, rc, ms);
|
||||
+ v = CAST(uint64_t, -1);
|
||||
+ break;
|
||||
}
|
||||
- file_regfree(&rx);
|
||||
if (v == CAST(uint64_t, -1))
|
||||
return -1;
|
||||
break;
|
@ -0,0 +1,226 @@
|
||||
diff --git a/src/apprentice.c b/src/apprentice.c
|
||||
index 21eac1e..781c5e1 100644
|
||||
--- a/src/apprentice.c
|
||||
+++ b/src/apprentice.c
|
||||
@@ -513,6 +513,9 @@ file_ms_free(struct magic_set *ms)
|
||||
free(ms->o.pbuf);
|
||||
free(ms->o.buf);
|
||||
free(ms->c.li);
|
||||
+#ifdef USE_C_LOCALE
|
||||
+ freelocale(ms->c_lc_ctype);
|
||||
+#endif
|
||||
free(ms);
|
||||
}
|
||||
|
||||
@@ -551,6 +554,10 @@ file_ms_alloc(int flags)
|
||||
ms->elf_notes_max = FILE_ELF_NOTES_MAX;
|
||||
ms->regex_max = FILE_REGEX_MAX;
|
||||
ms->bytes_max = FILE_BYTES_MAX;
|
||||
+#ifdef USE_C_LOCALE
|
||||
+ ms->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
|
||||
+ assert(ms->c_lc_ctype != NULL);
|
||||
+#endif
|
||||
return ms;
|
||||
free:
|
||||
free(ms);
|
||||
@@ -624,6 +631,7 @@ mlist_free_one(struct mlist *ml)
|
||||
if (ml->magic_rxcomp[i]) {
|
||||
file_regfree(ml->magic_rxcomp[i]);
|
||||
free(ml->magic_rxcomp[i]);
|
||||
+ ml->magic_rxcomp[i] = NULL;
|
||||
}
|
||||
}
|
||||
free(ml->magic_rxcomp);
|
||||
@@ -2714,7 +2722,8 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
|
||||
}
|
||||
if (m->type == FILE_REGEX) {
|
||||
file_regex_t rx;
|
||||
- int rc = file_regcomp(&rx, m->value.s, REG_EXTENDED);
|
||||
+ int rc = file_regcomp(ms, &rx, m->value.s,
|
||||
+ REG_EXTENDED);
|
||||
if (rc) {
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_regerror(&rx, rc, ms);
|
||||
diff --git a/src/file.h b/src/file.h
|
||||
index c0b5a7c..f049446 100644
|
||||
--- a/src/file.h
|
||||
+++ b/src/file.h
|
||||
@@ -173,13 +173,6 @@
|
||||
|
||||
typedef struct {
|
||||
const char *pat;
|
||||
-#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
|
||||
-#define USE_C_LOCALE
|
||||
- locale_t old_lc_ctype;
|
||||
- locale_t c_lc_ctype;
|
||||
-#else
|
||||
- char *old_lc_ctype;
|
||||
-#endif
|
||||
int rc;
|
||||
regex_t rx;
|
||||
} file_regex_t;
|
||||
@@ -487,6 +480,10 @@ struct magic_set {
|
||||
#define FILE_INDIR_MAX 50
|
||||
#define FILE_NAME_MAX 50
|
||||
#define FILE_REGEX_MAX 8192
|
||||
+#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
|
||||
+#define USE_C_LOCALE
|
||||
+ locale_t c_lc_ctype;
|
||||
+#endif
|
||||
};
|
||||
|
||||
/* Type for Unicode characters */
|
||||
@@ -574,9 +571,10 @@ protected int buffer_fill(const struct buffer *);
|
||||
|
||||
|
||||
|
||||
-protected int file_regcomp(file_regex_t *, const char *, int);
|
||||
-protected int file_regexec(file_regex_t *, const char *, size_t, regmatch_t *,
|
||||
+protected int file_regcomp(struct magic_set *, file_regex_t *, const char *,
|
||||
int);
|
||||
+protected int file_regexec(struct magic_set *, file_regex_t *, const char *,
|
||||
+ size_t, regmatch_t *, int);
|
||||
protected void file_regfree(file_regex_t *);
|
||||
protected void file_regerror(file_regex_t *, int, struct magic_set *);
|
||||
|
||||
diff --git a/src/funcs.c b/src/funcs.c
|
||||
index 6320cf2..1391a44 100644
|
||||
--- a/src/funcs.c
|
||||
+++ b/src/funcs.c
|
||||
@@ -613,13 +613,13 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
|
||||
file_regex_t rx;
|
||||
int rc, rv = -1;
|
||||
|
||||
- rc = file_regcomp(&rx, pat, REG_EXTENDED);
|
||||
+ rc = file_regcomp(ms, &rx, pat, REG_EXTENDED);
|
||||
if (rc) {
|
||||
file_regerror(&rx, rc, ms);
|
||||
} else {
|
||||
regmatch_t rm;
|
||||
int nm = 0;
|
||||
- while (file_regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) {
|
||||
+ while (file_regexec(ms, &rx, ms->o.buf, 1, &rm, 0) == 0) {
|
||||
ms->o.buf[rm.rm_so] = '\0';
|
||||
if (file_printf(ms, "%s%s", rep,
|
||||
rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1)
|
||||
@@ -634,34 +634,52 @@ out:
|
||||
}
|
||||
|
||||
protected int
|
||||
-file_regcomp(file_regex_t *rx, const char *pat, int flags)
|
||||
+file_regcomp(struct magic_set *ms, file_regex_t *rx, const char *pat, int flags)
|
||||
{
|
||||
#ifdef USE_C_LOCALE
|
||||
- rx->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
|
||||
- assert(rx->c_lc_ctype != NULL);
|
||||
- rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
|
||||
- assert(rx->old_lc_ctype != NULL);
|
||||
+ locale_t old = uselocale(ms->c_lc_ctype);
|
||||
+ assert(old != NULL);
|
||||
#else
|
||||
- rx->old_lc_ctype = setlocale(LC_CTYPE, NULL);
|
||||
- assert(rx->old_lc_ctype != NULL);
|
||||
- rx->old_lc_ctype = strdup(rx->old_lc_ctype);
|
||||
- assert(rx->old_lc_ctype != NULL);
|
||||
+ char old[1024];
|
||||
+ strlcpy(old, setlocale(LC_CTYPE, NULL), sizeof(old));
|
||||
(void)setlocale(LC_CTYPE, "C");
|
||||
#endif
|
||||
rx->pat = pat;
|
||||
|
||||
- return rx->rc = regcomp(&rx->rx, pat, flags);
|
||||
+ rx->rc = regcomp(&rx->rx, pat, flags);
|
||||
+
|
||||
+#ifdef USE_C_LOCALE
|
||||
+ uselocale(old);
|
||||
+#else
|
||||
+ (void)setlocale(LC_CTYPE, old);
|
||||
+#endif
|
||||
+ return rx->rc;
|
||||
}
|
||||
|
||||
protected int
|
||||
-file_regexec(file_regex_t *rx, const char *str, size_t nmatch,
|
||||
- regmatch_t* pmatch, int eflags)
|
||||
+file_regexec(struct magic_set *ms, file_regex_t *rx, const char *str,
|
||||
+ size_t nmatch, regmatch_t* pmatch, int eflags)
|
||||
{
|
||||
+#ifdef USE_C_LOCALE
|
||||
+ locale_t old = uselocale(ms->c_lc_ctype);
|
||||
+ assert(old != NULL);
|
||||
+#else
|
||||
+ char old[1024];
|
||||
+ strlcpy(old, setlocale(LC_CTYPE, NULL), sizeof(old));
|
||||
+ (void)setlocale(LC_CTYPE, "C");
|
||||
+#endif
|
||||
+ int rc;
|
||||
assert(rx->rc == 0);
|
||||
/* XXX: force initialization because glibc does not always do this */
|
||||
if (nmatch != 0)
|
||||
memset(pmatch, 0, nmatch * sizeof(*pmatch));
|
||||
- return regexec(&rx->rx, str, nmatch, pmatch, eflags);
|
||||
+ rc = regexec(&rx->rx, str, nmatch, pmatch, eflags);
|
||||
+#ifdef USE_C_LOCALE
|
||||
+ uselocale(old);
|
||||
+#else
|
||||
+ (void)setlocale(LC_CTYPE, old);
|
||||
+#endif
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
protected void
|
||||
@@ -669,13 +687,6 @@ file_regfree(file_regex_t *rx)
|
||||
{
|
||||
if (rx->rc == 0)
|
||||
regfree(&rx->rx);
|
||||
-#ifdef USE_C_LOCALE
|
||||
- (void)uselocale(rx->old_lc_ctype);
|
||||
- freelocale(rx->c_lc_ctype);
|
||||
-#else
|
||||
- (void)setlocale(LC_CTYPE, rx->old_lc_ctype);
|
||||
- free(rx->old_lc_ctype);
|
||||
-#endif
|
||||
}
|
||||
|
||||
protected void
|
||||
diff --git a/src/softmagic.c b/src/softmagic.c
|
||||
index 43338fc..b4052a6 100644
|
||||
--- a/src/softmagic.c
|
||||
+++ b/src/softmagic.c
|
||||
@@ -478,11 +478,11 @@ check_fmt(struct magic_set *ms, const char *fmt)
|
||||
if (strchr(fmt, '%') == NULL)
|
||||
return 0;
|
||||
|
||||
- rc = file_regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
|
||||
+ rc = file_regcomp(ms, &rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
|
||||
if (rc) {
|
||||
file_regerror(&rx, rc, ms);
|
||||
} else {
|
||||
- rc = file_regexec(&rx, fmt, 0, 0, 0);
|
||||
+ rc = file_regexec(ms, &rx, fmt, 0, 0, 0);
|
||||
rv = !rc;
|
||||
}
|
||||
file_regfree(&rx);
|
||||
@@ -2003,11 +2003,12 @@ alloc_regex(struct magic_set *ms, struct magic *m)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- rc = file_regcomp(rx, m->value.s, REG_EXTENDED | REG_NEWLINE |
|
||||
+ rc = file_regcomp(ms, rx, m->value.s, REG_EXTENDED | REG_NEWLINE |
|
||||
((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
|
||||
if (rc == 0)
|
||||
return rx;
|
||||
|
||||
+fprintf(stderr, "regcomp %s %d\n", m->value.s, rc);
|
||||
file_regerror(rx, rc, ms);
|
||||
file_regfree(rx);
|
||||
free(rx);
|
||||
@@ -2225,7 +2226,7 @@ magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache)
|
||||
search = CCAST(char *, "");
|
||||
copy = NULL;
|
||||
}
|
||||
- rc = file_regexec(rx, RCAST(const char *, search),
|
||||
+ rc = file_regexec(ms, rx, RCAST(const char *, search),
|
||||
1, &pmatch, 0);
|
||||
free(copy);
|
||||
switch (rc) {
|
@ -0,0 +1,28 @@
|
||||
From d1a00ae92b2cf09298615cf3aba474d8fec7380f Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Mon, 18 Apr 2022 21:46:43 +0000
|
||||
Subject: [PATCH] From Dirk Mueller:
|
||||
|
||||
when name/use was used, the regex caching table was incorrectly
|
||||
initialized, which led to false or missing matches.
|
||||
---
|
||||
src/apprentice.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/apprentice.c b/src/apprentice.c
|
||||
index 804c0e33e..992102b4e 100644
|
||||
--- a/src/apprentice.c
|
||||
+++ b/src/apprentice.c
|
||||
@@ -3678,11 +3678,11 @@ file_magicfind(struct magic_set *ms, const char *name, struct mlist *v)
|
||||
continue;
|
||||
if (strcmp(ma[i].value.s, name) == 0) {
|
||||
v->magic = &ma[i];
|
||||
+ v->magic_rxcomp = &(ml->magic_rxcomp[i]);
|
||||
for (j = i + 1; j < ml->nmagic; j++)
|
||||
if (ma[j].cont_level == 0)
|
||||
break;
|
||||
v->nmagic = j - i;
|
||||
- v->magic_rxcomp = ml->magic_rxcomp;
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
diff --git a/src/apprentice.c b/src/apprentice.c
|
||||
index 781c5e1..50a91cf 100644
|
||||
--- a/src/apprentice.c
|
||||
+++ b/src/apprentice.c
|
||||
@@ -2724,11 +2724,9 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
|
||||
file_regex_t rx;
|
||||
int rc = file_regcomp(ms, &rx, m->value.s,
|
||||
REG_EXTENDED);
|
||||
- if (rc) {
|
||||
- if (ms->flags & MAGIC_CHECK)
|
||||
- file_regerror(&rx, rc, ms);
|
||||
+ if (rc == 0) {
|
||||
+ file_regfree(&rx);
|
||||
}
|
||||
- file_regfree(&rx);
|
||||
return rc ? -1 : 0;
|
||||
}
|
||||
return 0;
|
||||
diff --git a/src/file.h b/src/file.h
|
||||
index f049446..ee15855 100644
|
||||
--- a/src/file.h
|
||||
+++ b/src/file.h
|
||||
@@ -171,11 +171,7 @@
|
||||
#define FILE_COMPILE 2
|
||||
#define FILE_LIST 3
|
||||
|
||||
-typedef struct {
|
||||
- const char *pat;
|
||||
- int rc;
|
||||
- regex_t rx;
|
||||
-} file_regex_t;
|
||||
+typedef regex_t file_regex_t;
|
||||
|
||||
struct buffer {
|
||||
int fd;
|
||||
@@ -576,7 +572,6 @@ protected int file_regcomp(struct magic_set *, file_regex_t *, const char *,
|
||||
protected int file_regexec(struct magic_set *, file_regex_t *, const char *,
|
||||
size_t, regmatch_t *, int);
|
||||
protected void file_regfree(file_regex_t *);
|
||||
-protected void file_regerror(file_regex_t *, int, struct magic_set *);
|
||||
|
||||
typedef struct {
|
||||
char *buf;
|
||||
diff --git a/src/funcs.c b/src/funcs.c
|
||||
index 1391a44..df436eb 100644
|
||||
--- a/src/funcs.c
|
||||
+++ b/src/funcs.c
|
||||
@@ -614,9 +614,7 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
|
||||
int rc, rv = -1;
|
||||
|
||||
rc = file_regcomp(ms, &rx, pat, REG_EXTENDED);
|
||||
- if (rc) {
|
||||
- file_regerror(&rx, rc, ms);
|
||||
- } else {
|
||||
+ if (rc == 0) {
|
||||
regmatch_t rm;
|
||||
int nm = 0;
|
||||
while (file_regexec(ms, &rx, ms->o.buf, 1, &rm, 0) == 0) {
|
||||
@@ -644,16 +642,22 @@ file_regcomp(struct magic_set *ms, file_regex_t *rx, const char *pat, int flags)
|
||||
strlcpy(old, setlocale(LC_CTYPE, NULL), sizeof(old));
|
||||
(void)setlocale(LC_CTYPE, "C");
|
||||
#endif
|
||||
- rx->pat = pat;
|
||||
-
|
||||
- rx->rc = regcomp(&rx->rx, pat, flags);
|
||||
+ int rc;
|
||||
+ rc = regcomp(rx, pat, flags);
|
||||
|
||||
#ifdef USE_C_LOCALE
|
||||
uselocale(old);
|
||||
#else
|
||||
(void)setlocale(LC_CTYPE, old);
|
||||
#endif
|
||||
- return rx->rc;
|
||||
+ if (rc > 0 && (ms->flags & MAGIC_CHECK)) {
|
||||
+ char errmsg[512];
|
||||
+
|
||||
+ (void)regerror(rc, rx, errmsg, sizeof(errmsg));
|
||||
+ file_magerror(ms, "regex error %d for `%s', (%s)", rc, pat,
|
||||
+ errmsg);
|
||||
+ }
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
protected int
|
||||
@@ -669,11 +673,10 @@ file_regexec(struct magic_set *ms, file_regex_t *rx, const char *str,
|
||||
(void)setlocale(LC_CTYPE, "C");
|
||||
#endif
|
||||
int rc;
|
||||
- assert(rx->rc == 0);
|
||||
/* XXX: force initialization because glibc does not always do this */
|
||||
if (nmatch != 0)
|
||||
memset(pmatch, 0, nmatch * sizeof(*pmatch));
|
||||
- rc = regexec(&rx->rx, str, nmatch, pmatch, eflags);
|
||||
+ rc = regexec(rx, str, nmatch, pmatch, eflags);
|
||||
#ifdef USE_C_LOCALE
|
||||
uselocale(old);
|
||||
#else
|
||||
@@ -685,18 +688,7 @@ file_regexec(struct magic_set *ms, file_regex_t *rx, const char *str,
|
||||
protected void
|
||||
file_regfree(file_regex_t *rx)
|
||||
{
|
||||
- if (rx->rc == 0)
|
||||
- regfree(&rx->rx);
|
||||
-}
|
||||
-
|
||||
-protected void
|
||||
-file_regerror(file_regex_t *rx, int rc, struct magic_set *ms)
|
||||
-{
|
||||
- char errmsg[512];
|
||||
-
|
||||
- (void)regerror(rc, &rx->rx, errmsg, sizeof(errmsg));
|
||||
- file_magerror(ms, "regex error %d for `%s', (%s)", rc, rx->pat,
|
||||
- errmsg);
|
||||
+ regfree(rx);
|
||||
}
|
||||
|
||||
protected file_pushbuf_t *
|
||||
diff --git a/src/softmagic.c b/src/softmagic.c
|
||||
index b4052a6..f469a12 100644
|
||||
--- a/src/softmagic.c
|
||||
+++ b/src/softmagic.c
|
||||
@@ -474,14 +474,13 @@ check_fmt(struct magic_set *ms, const char *fmt)
|
||||
{
|
||||
file_regex_t rx;
|
||||
int rc, rv = -1;
|
||||
+ const char* pat = "%[-0-9\\.]*s";
|
||||
|
||||
if (strchr(fmt, '%') == NULL)
|
||||
return 0;
|
||||
|
||||
- rc = file_regcomp(ms, &rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
|
||||
- if (rc) {
|
||||
- file_regerror(&rx, rc, ms);
|
||||
- } else {
|
||||
+ rc = file_regcomp(ms, &rx, pat, REG_EXTENDED|REG_NOSUB);
|
||||
+ if (rc == 0) {
|
||||
rc = file_regexec(ms, &rx, fmt, 0, 0, 0);
|
||||
rv = !rc;
|
||||
}
|
||||
@@ -2008,9 +2007,6 @@ alloc_regex(struct magic_set *ms, struct magic *m)
|
||||
if (rc == 0)
|
||||
return rx;
|
||||
|
||||
-fprintf(stderr, "regcomp %s %d\n", m->value.s, rc);
|
||||
- file_regerror(rx, rc, ms);
|
||||
- file_regfree(rx);
|
||||
free(rx);
|
||||
return NULL;
|
||||
}
|
||||
@@ -2243,12 +2239,9 @@ magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache)
|
||||
break;
|
||||
|
||||
default:
|
||||
- file_regerror(rx, rc, ms);
|
||||
- v = CAST(uint64_t, -1);
|
||||
+ return -1;
|
||||
break;
|
||||
}
|
||||
- if (v == CAST(uint64_t, -1))
|
||||
- return -1;
|
||||
break;
|
||||
}
|
||||
case FILE_INDIRECT:
|
@ -0,0 +1,58 @@
|
||||
From a4b3abc4104d8a4eeb84a6242f2f1a830204a539 Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Sat, 12 Mar 2022 15:09:47 +0000
|
||||
Subject: [PATCH] Combine regex's to improve performance adjusting strength to
|
||||
preserve ranking (Dirk Mueller)
|
||||
|
||||
---
|
||||
magic/Magdir/make | 29 +++++++----------------------
|
||||
1 file changed, 7 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/magic/Magdir/make b/magic/Magdir/make
|
||||
index f522b4f18..1abdf7a3e 100644
|
||||
--- a/magic/Magdir/make
|
||||
+++ b/magic/Magdir/make
|
||||
@@ -1,36 +1,21 @@
|
||||
#------------------------------------------------------------------------------
|
||||
-# $File: make,v 1.4 2018/05/29 17:26:02 christos Exp $
|
||||
+# $File: make,v 1.5 2022/03/12 15:09:47 christos Exp $
|
||||
# make: file(1) magic for makefiles
|
||||
#
|
||||
# URL: https://en.wikipedia.org/wiki/Make_(software)
|
||||
-0 regex/100l \^CFLAGS makefile script text
|
||||
-!:mime text/x-makefile
|
||||
-0 regex/100l \^VPATH makefile script text
|
||||
-!:mime text/x-makefile
|
||||
-0 regex/100l \^LDFLAGS makefile script text
|
||||
-!:mime text/x-makefile
|
||||
-0 regex/100l \^all: makefile script text
|
||||
-!:mime text/x-makefile
|
||||
-0 regex/100l \^\\.PRECIOUS makefile script text
|
||||
+0 regex/100l \^(CFLAGS|VPATH|LDFLAGS|all:|\\.PRECIOUS) makefile script text
|
||||
!:mime text/x-makefile
|
||||
+!:strength -15
|
||||
# Update: Joerg Jenderek
|
||||
# Reference: https://www.freebsd.org/cgi/man.cgi?make(1)
|
||||
# exclude grub-core\lib\libgcrypt\mpi\Makefile.am with "#BEGIN_ASM_LIST"
|
||||
# by additional escaping point character
|
||||
-0 regex/100l \^\\.BEGIN BSD makefile script text
|
||||
-!:mime text/x-makefile
|
||||
-!:ext /mk
|
||||
-!:strength +10
|
||||
# exclude MS Windows help file CoNtenT with ":include FOOBAR.CNT"
|
||||
# and NSIS script with "!include" by additional escaping point character
|
||||
-0 regex/100l \^\\.include BSD makefile script text
|
||||
-!:mime text/x-makefile
|
||||
-!:ext /mk
|
||||
-!:strength +10
|
||||
-0 regex/100l \^\\.endif BSD makefile script text
|
||||
+0 regex/100l \^\\.(BEGIN|endif|include) BSD makefile script text
|
||||
!:mime text/x-makefile
|
||||
!:ext /mk
|
||||
-!:strength +10
|
||||
-0 regex/100l \^SUBDIRS automake makefile script text
|
||||
+!:strength -10
|
||||
+0 regex/100l \^SUBDIRS[[:space:]]+= automake makefile script text
|
||||
!:mime text/x-makefile
|
||||
-!:strength +10
|
||||
+!:strength -15
|
@ -0,0 +1,86 @@
|
||||
diff --git a/magic/Magdir/archive b/magic/Magdir/archive
|
||||
index 99798b0..945f536 100644
|
||||
--- a/magic/Magdir/archive
|
||||
+++ b/magic/Magdir/archive
|
||||
@@ -150,7 +150,7 @@
|
||||
# Incremental snapshot gnu-tar format from:
|
||||
# https://www.gnu.org/software/tar/manual/html_node/Snapshot-Files.html
|
||||
0 string GNU\ tar- GNU tar incremental snapshot data
|
||||
->&0 regex [0-9]\.[0-9]+-[0-9]+ version %s
|
||||
+>&0 regex [0-9]\\.[0-9]+-[0-9]+ version %s
|
||||
|
||||
# cpio archives
|
||||
#
|
||||
diff --git a/magic/Magdir/ctf b/magic/Magdir/ctf
|
||||
index ebea8f3..d91684d 100644
|
||||
--- a/magic/Magdir/ctf
|
||||
+++ b/magic/Magdir/ctf
|
||||
@@ -20,4 +20,4 @@
|
||||
# CTF metadata (plain text)
|
||||
0 string /*\x20CTF\x20 Common Trace Format (CTF) plain text metadata
|
||||
!:strength + 5 # this is to make sure we beat C
|
||||
->&0 regex [0-9]+\.[0-9]+ \b, v%s
|
||||
+>&0 regex [0-9]+\\.[0-9]+ \b, v%s
|
||||
diff --git a/magic/Magdir/geo b/magic/Magdir/geo
|
||||
index d72e514..dda5f73 100644
|
||||
--- a/magic/Magdir/geo
|
||||
+++ b/magic/Magdir/geo
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
-# $File: geo,v 1.7 2019/04/19 00:42:27 christos Exp $
|
||||
+# $File: geo,v 1.8 2022/03/24 15:48:58 christos Exp $
|
||||
# Geo- files from Kurt Schwehr <schwehr@ccom.unh.edu>
|
||||
|
||||
######################################################################
|
||||
@@ -28,8 +28,8 @@
|
||||
# Knudsen subbottom chirp profiler - Binary File Format: B9
|
||||
# KEB D409-03167 V1.75 Huffman
|
||||
0 string KEB\ Knudsen seismic KEL binary (KEB) -
|
||||
->4 regex [-A-Z0-9]* Software: %s
|
||||
->>&1 regex V[0-9]*\.[0-9]* version %s
|
||||
+>4 regex [-A-Z0-9]+ Software: %s
|
||||
+>>&1 regex V[0-9]+\\.[0-9]+ version %s
|
||||
|
||||
######################################################################
|
||||
#
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
# Caris LIDAR format for LADS comes as two parts... ascii location file and binary waveform data
|
||||
0 string HCA LADS Caris Ascii Format (CAF) bathymetric lidar
|
||||
->4 regex [0-9]*\.[0-9]* version %s
|
||||
+>4 regex [0-9]+\\.[0-9]+ version %s
|
||||
|
||||
0 string HCB LADS Caris Binary Format (CBF) bathymetric lidar waveform data
|
||||
>3 byte x version %d .
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
# mb121 https://www.saic.com/maritime/gsf/
|
||||
8 string GSF-v SAIC generic sensor format (GSF) sonar data,
|
||||
->&0 regex [0-9]*\.[0-9]* version %s
|
||||
+>&0 regex [0-9]+\\.[0-9]+ version %s
|
||||
|
||||
# MGD77 - https://www.ngdc.noaa.gov/mgg/dat/geodas/docs/mgd77.htm
|
||||
# mb161
|
||||
diff --git a/magic/Magdir/windows b/magic/Magdir/windows
|
||||
index 8a7923f..1247e03 100644
|
||||
--- a/magic/Magdir/windows
|
||||
+++ b/magic/Magdir/windows
|
||||
@@ -358,7 +358,7 @@
|
||||
# skip space at beginning
|
||||
>0 string \040
|
||||
# name without extension and greater character or name with hlp extension
|
||||
->>1 regex/c \^([^\xd>]*|.*\.hlp) MS Windows help file Content, based "%s"
|
||||
+>>1 regex/c \^([^\xd>]*|.*\\.hlp) MS Windows help file Content, based "%s"
|
||||
!:mime text/plain
|
||||
!:apple ????TEXT
|
||||
!:ext cnt
|
||||
@@ -535,7 +535,7 @@
|
||||
# http://www.winfaq.de/faq_html/Content/tip2500/onlinefaq.php?h=tip2653.htm
|
||||
# https://msdn.microsoft.com/en-us/library/windows/desktop/cc144102.aspx
|
||||
# .ShellClassInfo DeleteOnCopy LocalizedFileNames ASCII coded case-independent
|
||||
->>&0 regex/c \^(\.ShellClassInfo|DeleteOnCopy|LocalizedFileNames)] Windows desktop.ini
|
||||
+>>&0 regex/1024c \^(\\.ShellClassInfo|DeleteOnCopy|LocalizedFileNames)] Windows desktop.ini
|
||||
!:mime application/x-wine-extension-ini
|
||||
#!:mime text/plain
|
||||
# https://support.microsoft.com/kb/84709/
|
@ -0,0 +1,79 @@
|
||||
From 14b5d7aa0b55275969809fdf84e8a8caee857c0f Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Mon, 18 Apr 2022 21:38:10 +0000
|
||||
Subject: [PATCH] From Dirk Mueller: * regex rules need literal dots escaped,
|
||||
otherwise they are considered any character * literal search strings can be
|
||||
searched using search rather than the much more expensive regex * use
|
||||
standard xml declaration search as used in other format matchers * only match
|
||||
the first 1024 bytes, the information we look for should be in the very
|
||||
first tag * remove unnecessary parentheses
|
||||
|
||||
---
|
||||
magic/Magdir/dataone | 28 ++++++++++++++--------------
|
||||
1 file changed, 14 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/magic/Magdir/dataone b/magic/Magdir/dataone
|
||||
index 8ef3f7981..566633eff 100644
|
||||
--- a/magic/Magdir/dataone
|
||||
+++ b/magic/Magdir/dataone
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
-# $File: dataone,v 1.2 2019/04/19 00:42:27 christos Exp $
|
||||
+# $File: dataone,v 1.3 2022/04/18 21:38:10 christos Exp $
|
||||
#
|
||||
# DataONE- files from Dave Vieglais <dave.vieglais@gmail.com> &
|
||||
# Pratik Shrivastava <pratikshrivastava23@gmail.com>
|
||||
@@ -9,39 +9,39 @@
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# EML (Ecological Metadata Language Format)
|
||||
-0 string <?xml
|
||||
->&0 regex (eml)-[0-9].[0-9].[0-9]+ eml://ecoinformatics.org/%s
|
||||
+0 string \<?xml\ version=
|
||||
+>&0 regex/1024 eml-[0-9]\\.[0-9]\\.[0-9]+ eml://ecoinformatics.org/%s
|
||||
|
||||
# onedcx (DataONE Dublin Core Extended v1.0)
|
||||
->&0 regex (onedcx/v)[0-9].[0-9]+ https://ns.dataone.org/metadata/schema/onedcx/v1.0
|
||||
+>&0 regex/1024 onedcx/v[0-9]\\.[0-9]+ https://ns.dataone.org/metadata/schema/onedcx/v1.0
|
||||
|
||||
# FGDC-STD-001-1998 (Content Standard for Digital Geospatial Metadata,
|
||||
# version 001-1998)
|
||||
->&0 regex fgdc FGDC-STD-001-1998
|
||||
+>&0 search/1024 fgdc FGDC-STD-001-1998
|
||||
|
||||
# Mercury (Oak Ridge National Lab Mercury Metadata version 1.0)
|
||||
->&0 regex (mercury/terms/v)[0-9].[0-9] https://purl.org/ornl/schema/mercury/terms/v1.0
|
||||
+>&0 regex/1024 mercury/terms/v[0-9]\\.[0-9] https://purl.org/ornl/schema/mercury/terms/v1.0
|
||||
|
||||
# ISOTC211 (Geographic MetaData (GMD) Extensible Markup Language)
|
||||
->&0 regex isotc211
|
||||
->>&0 regex eng;USA https://www.isotc211.org/2005/gmd
|
||||
+>&0 search/1024 isotc211
|
||||
+>>&0 search/1024 eng;USA https://www.isotc211.org/2005/gmd
|
||||
|
||||
# ISOTC211 (NOAA Variant Geographic MetaData (GMD) Extensible Markup Language)
|
||||
->>&0 regex gov.noaa.nodc:[0-9]+ https://www.isotc211.org/2005/gmd-noaa
|
||||
+>>&0 regex/1024 gov\\.noaa\\.nodc:[0-9]+ https://www.isotc211.org/2005/gmd-noaa
|
||||
|
||||
# ISOTC211 PANGAEA Variant Geographic MetaData (GMD) Extensible Markup Language
|
||||
->>&0 regex pangaea.dataset[0-9][0-9][0-9][0-9][0-9][0-9]+ https://www.isotc211.org/2005/gmd-pangaea
|
||||
+>>&0 regex/1024 pangaea\\.dataset[0-9][0-9][0-9][0-9][0-9][0-9]+ https://www.isotc211.org/2005/gmd-pangaea
|
||||
!:mime text/xml
|
||||
|
||||
|
||||
# Object Reuse and Exchange Vocabulary
|
||||
-0 string <?xml
|
||||
->&0 regex rdf
|
||||
->>&0 regex openarchives https://www.openarchives.org/ore/terms
|
||||
+0 string \<?xml\ version=
|
||||
+>&0 search/1024 rdf
|
||||
+>>&0 search/1024 openarchives https://www.openarchives.org/ore/terms
|
||||
!:mime application/rdf+xml
|
||||
|
||||
|
||||
# Dryad Metadata Application Profile Version 3.1
|
||||
0 string <DryadData
|
||||
->&0 regex (dryad-bibo/v)[0-9].[0-9] https://datadryad.org/profile/v3.1
|
||||
+>&0 regex/1024 dryad-bibo/v[0-9]\\.[0-9] https://datadryad.org/profile/v3.1
|
||||
!:mime text/xml
|
@ -0,0 +1,319 @@
|
||||
diff --git a/magic/Magdir/python b/magic/Magdir/python
|
||||
index 9d306c0..bc5163e 100644
|
||||
--- a/magic/Magdir/python
|
||||
+++ b/magic/Magdir/python
|
||||
@@ -10,211 +10,211 @@
|
||||
# MAGIC as specified in Python/import.c (1.0 to 3.7)
|
||||
# two bytes of magic followed by "\r\n" in little endian order
|
||||
0 belong 0x02099900 python 1.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x03099900 python 1.1/1.2 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x892e0d0a python 1.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x04170d0a python 1.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x994e0d0a python 1.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xfcc40d0a python 1.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xfdc40d0a python 1.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x87c60d0a python 2.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x88c60d0a python 2.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2aeb0d0a python 2.1 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2beb0d0a python 2.1 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2ded0d0a python 2.2 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2eed0d0a python 2.2 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x3bf20d0a python 2.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x3cf20d0a python 2.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x45f20d0a python 2.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x59f20d0a python 2.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x63f20d0a python 2.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x6df20d0a python 2.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x6ef20d0a python 2.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x77f20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x81f20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x8bf20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x8cf20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x95f20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x9ff20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xa9f20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xb3f20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xb4f20d0a python 2.5 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xc7f20d0a python 2.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xd1f20d0a python 2.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xd2f20d0a python 2.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xdbf20d0a python 2.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xe5f20d0a python 2.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xeff20d0a python 2.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xf9f20d0a python 2.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x03f30d0a python 2.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x04f30d0a python 2.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xb80b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xc20b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xcc0b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xd60b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xe00b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xea0b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xf40b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xf50b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xff0b0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x090c0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x130c0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x1d0c0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x1f0c0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x270c0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x3b0c0d0a python 3.0 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x450c0d0a python 3.1 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x4f0c0d0a python 3.1 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x580c0d0a python 3.2 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x620c0d0a python 3.2 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x6c0c0d0a python 3.2 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x760c0d0a python 3.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x800c0d0a python 3.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x8a0c0d0a python 3.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x940c0d0a python 3.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x9e0c0d0a python 3.3 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xb20c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xbc0c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xc60c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xd00c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xda0c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xe40c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xee0c0d0a python 3.4 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0xf80c0d0a python 3.5.1- byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x020d0d0a python 3.5.1- byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x0c0d0d0a python 3.5.1- byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x160d0d0a python 3.5.1- byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x170d0d0a python 3.5.2+ byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x200d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x210d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2a0d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2b0d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2c0d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2d0d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x2f0d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x300d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x310d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x320d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x330d0d0a python 3.6 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x3e0d0d0a python 3.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x3f0d0d0a python 3.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x400d0d0a python 3.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x410d0d0a python 3.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x420d0d0a python 3.7 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x480d0d0a python 3.8 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x490d0d0a python 3.8 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x520d0d0a python 3.8 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x530d0d0a python 3.8 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x540d0d0a python 3.8 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x550d0d0a python 3.8 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x5c0d0d0a python 3.9 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x5d0d0d0a python 3.9 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x5e0d0d0a python 3.9 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x5f0d0d0a python 3.9 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x600d0d0a python 3.9 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
0 belong 0x610d0d0a python 3.9 byte-compiled
|
||||
-!:mime text/x-bytecode.python
|
||||
+!:mime application/x-bytecode.python
|
||||
|
||||
0 search/1/w #!\040/usr/bin/python Python script text executable
|
||||
!:strength + 15
|
@ -0,0 +1,62 @@
|
||||
From 95c993ff6bdfe92a7f519c4db60157a421e65b38 Mon Sep 17 00:00:00 2001
|
||||
From: Siteshwar Vashisht <svashisht@redhat.com>
|
||||
Date: Thu, 21 Feb 2019 15:26:38 +0100
|
||||
Subject: [PATCH] Upstream says it's up to distributions to add a way to
|
||||
support local-magic.
|
||||
|
||||
---
|
||||
magic/magic.local | 3 +++
|
||||
src/Makefile.am | 2 +-
|
||||
src/Makefile.in | 2 +-
|
||||
src/apprentice.c | 2 +-
|
||||
4 files changed, 6 insertions(+), 3 deletions(-)
|
||||
create mode 100644 magic/magic.local
|
||||
|
||||
diff --git a/magic/magic.local b/magic/magic.local
|
||||
new file mode 100644
|
||||
index 0000000..283a863
|
||||
--- /dev/null
|
||||
+++ b/magic/magic.local
|
||||
@@ -0,0 +1,3 @@
|
||||
+# Magic local data for file(1) command.
|
||||
+# Insert here your local magic data. Format is described in magic(5).
|
||||
+
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index 3f67f2c..b43cb8e 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -1,4 +1,4 @@
|
||||
-MAGIC = $(pkgdatadir)/magic
|
||||
+MAGIC = /etc/magic:$(pkgdatadir)/magic
|
||||
lib_LTLIBRARIES = libmagic.la
|
||||
nodist_include_HEADERS = magic.h
|
||||
|
||||
diff --git a/src/Makefile.in b/src/Makefile.in
|
||||
index 59f3b5e..a8f56cf 100644
|
||||
--- a/src/Makefile.in
|
||||
+++ b/src/Makefile.in
|
||||
@@ -356,7 +356,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
-MAGIC = $(pkgdatadir)/magic
|
||||
+MAGIC = /etc/magic:$(pkgdatadir)/magic
|
||||
lib_LTLIBRARIES = libmagic.la
|
||||
nodist_include_HEADERS = magic.h
|
||||
AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
|
||||
diff --git a/src/apprentice.c b/src/apprentice.c
|
||||
index 1437bcc..b609dd1 100644
|
||||
--- a/src/apprentice.c
|
||||
+++ b/src/apprentice.c
|
||||
@@ -460,7 +460,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
|
||||
#ifndef COMPILE_ONLY
|
||||
map = apprentice_map(ms, fn);
|
||||
if (map == NULL) {
|
||||
- if (ms->flags & MAGIC_CHECK)
|
||||
+ if (ms->flags & MAGIC_CHECK && strcmp("/etc/magic", fn) != 0)
|
||||
file_magwarn(ms, "using regular magic file `%s'", fn);
|
||||
map = apprentice_load(ms, fn, action);
|
||||
if (map == NULL)
|
||||
--
|
||||
2.25.4
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue