diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
--- libmagic.orig/apprentice.c Tue Nov 19 22:01:12 2013
-+++ libmagic/apprentice.c Sun Sep 21 18:30:39 2014
++++ libmagic/apprentice.c Sun Dec 28 16:29:05 2014
@@ -29,6 +29,8 @@
* apprentice - make one pass through /etc/magic, learning its secrets.
*/
NULL) {
file_oomem(ms, sizeof(*mp) * mset[i].max);
return -1;
-@@ -939,13 +952,20 @@
+@@ -939,13 +952,19 @@
load_1(struct magic_set *ms, int action, const char *fn, int *errs,
struct magic_entry_set *mset)
{
- if (f == NULL) {
+ php_stream *stream;
+
-++
++
+ ms->file = fn;
+ stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL);
+
if (errno != ENOENT)
file_error(ms, errno, "cannot read magic file `%s'",
fn);
-@@ -955,8 +975,7 @@
+@@ -955,8 +974,7 @@
memset(&me, 0, sizeof(me));
/* read and parse this file */
if (len == 0) /* null line, garbage, etc */
continue;
if (line[len - 1] == '\n') {
-@@ -1014,8 +1033,7 @@
+@@ -1014,8 +1032,7 @@
}
if (me.mp)
(void)addentry(ms, &me, mset);
}
/*
-@@ -1094,7 +1112,7 @@
+@@ -1094,7 +1111,7 @@
mentrycount += me[i].cont_count;
slen = sizeof(**ma) * mentrycount;
file_oomem(ms, slen);
return -1;
}
-@@ -1116,8 +1134,8 @@
+@@ -1116,8 +1133,8 @@
if (me == NULL)
return;
for (i = 0; i < nme; i++)
}
private struct magic_map *
-@@ -1126,18 +1144,20 @@
+@@ -1126,18 +1143,19 @@
int errs = 0;
uint32_t i, j;
size_t files = 0, maxfiles = 0;
+ php_stream *dir;
+ php_stream_dirent d;
+
-+
+
memset(mset, 0, sizeof(mset));
ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */
{
file_oomem(ms, sizeof(*map));
return NULL;
-@@ -1148,22 +1168,26 @@
+@@ -1148,22 +1166,26 @@
(void)fprintf(stderr, "%s\n", usg_hdr);
/* load directory or file */
continue;
}
if (files >= maxfiles) {
-@@ -1171,23 +1195,23 @@
+@@ -1171,23 +1193,22 @@
maxfiles = (maxfiles + 1) * 2;
mlen = maxfiles * sizeof(*filearr);
if ((filearr = CAST(char **,
file_oomem(ms, mlen);
- free(mfn);
- closedir(dir);
-+ efree(mfn);
+ php_stream_closedir(dir);
errs++;
goto out;
} else
load_1(ms, action, fn, &errs, mset);
if (errs)
-@@ -1226,9 +1250,9 @@
+@@ -1226,9 +1247,9 @@
if (errs) {
for (j = 0; j < MAGIC_SETS; j++) {
if (map->magic[j])
return NULL;
}
return map;
-@@ -1248,7 +1272,7 @@
+@@ -1248,7 +1269,7 @@
* the sign extension must have happened.
*/
case FILE_BYTE:
break;
case FILE_SHORT:
case FILE_BESHORT:
-@@ -1516,7 +1540,7 @@
+@@ -1516,7 +1537,7 @@
if (me->cont_count == me->max_count) {
struct magic *nm;
size_t cnt = me->max_count + ALLOC_CHUNK;
sizeof(*nm) * cnt))) == NULL) {
file_oomem(ms, sizeof(*nm) * cnt);
return -1;
-@@ -1531,7 +1555,7 @@
+@@ -1531,7 +1552,7 @@
static const size_t len = sizeof(*m) * ALLOC_CHUNK;
if (me->mp != NULL)
return 1;
file_oomem(ms, len);
return -1;
}
-@@ -1704,7 +1728,7 @@
+@@ -1704,7 +1725,7 @@
m->type = get_standard_integer_type(l, &l);
else if (*l == 's' && !isalpha((unsigned char)l[1])) {
m->type = FILE_STRING;
}
}
}
-@@ -1717,6 +1741,10 @@
+@@ -1717,6 +1738,10 @@
if (m->type == FILE_INVALID) {
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "type `%s' invalid", l);
return -1;
}
-@@ -1725,7 +1753,7 @@
+@@ -1725,7 +1750,7 @@
m->mask_op = 0;
if (*l == '~') {
m->mask_op |= FILE_OPINVERSE;
else if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "'~' invalid for string types");
-@@ -1734,7 +1762,7 @@
+@@ -1734,7 +1759,7 @@
m->str_range = 0;
m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0;
if ((op = get_op(*l)) != -1) {
uint64_t val;
++l;
m->mask_op |= op;
-@@ -1925,11 +1953,6 @@
+@@ -1925,11 +1950,6 @@
if (check_format(ms, m) == -1)
return -1;
}
m->mimetype[0] = '\0'; /* initialise MIME type to none */
return 0;
}
-@@ -2575,59 +2598,76 @@
+@@ -2575,59 +2595,75 @@
private struct magic_map *
apprentice_map(struct magic_set *ms, const char *fn)
{
- fd = -1;
- if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
+
-++
++
+ if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
file_oomem(ms, sizeof(*map));
+ efree(map);
if (*ptr != MAGICNO) {
if (swap4(*ptr) != MAGICNO) {
file_error(ms, 0, "bad magic in `%s'", dbname);
-@@ -2641,17 +2681,29 @@
+@@ -2641,17 +2677,29 @@
else
version = ptr[1];
if (version != VERSIONNO) {
}
map->magic[0] = CAST(struct magic *, map->p) + 1;
nentries = 0;
-@@ -2664,22 +2716,29 @@
+@@ -2664,22 +2712,29 @@
map->magic[i + 1] = map->magic[i] + map->nmagic[i];
nentries += map->nmagic[i];
}
return NULL;
}
-@@ -2700,14 +2759,19 @@
+@@ -2700,14 +2755,18 @@
char *dbname;
int rv = -1;
uint32_t i;
+ php_stream *stream;
+
-+
+
- dbname = mkdbname(ms, fn, 1);
+ dbname = mkdbname(ms, fn, 0);
file_error(ms, errno, "cannot open `%s'", dbname);
goto out;
}
-@@ -2717,31 +2781,33 @@
+@@ -2717,31 +2776,33 @@
goto out;
}
return rv;
}
-@@ -2754,6 +2820,7 @@
- {
- const char *p, *q;
- char *buf;
-+
- if (strip) {
- if ((p = strrchr(fn, '/')) != NULL)
-@@ -2775,16 +2842,18 @@
+@@ -2775,16 +2836,18 @@
q++;
/* Compatibility with old code that looked in .mime */
if (ms->flags & MAGIC_MIME) {
/* Compatibility with old code that looked in .mime */
if (strstr(p, ".mime") != NULL)
-@@ -2874,7 +2943,7 @@
+@@ -2874,7 +2937,7 @@
m->offset = swap4((uint32_t)m->offset);
m->in_offset = swap4((uint32_t)m->in_offset);
m->lineno = swap4((uint32_t)m->lineno);
}
diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
--- libmagic.orig/ascmagic.c Thu Feb 13 00:20:53 2014
-+++ libmagic/ascmagic.c Wed Aug 27 12:35:45 2014
++++ libmagic/ascmagic.c Sun Nov 9 19:16:18 2014
@@ -139,7 +139,7 @@
/* malloc size is a conservative overestimate; could be
improved, or at least realloced after conversion. */
}
diff -u libmagic.orig/cdf.c libmagic/cdf.c
--- libmagic.orig/cdf.c Tue Feb 26 17:20:42 2013
-+++ libmagic/cdf.c Wed Aug 27 12:35:45 2014
++++ libmagic/cdf.c Sun Nov 9 19:16:18 2014
@@ -35,7 +35,7 @@
#include "file.h"
} else {
diff -u libmagic.orig/cdf.h libmagic/cdf.h
--- libmagic.orig/cdf.h Thu Jun 21 00:19:55 2012
-+++ libmagic/cdf.h Wed Aug 27 12:35:45 2014
++++ libmagic/cdf.h Sun Nov 9 19:16:18 2014
@@ -35,10 +35,12 @@
#ifndef _H_CDF_
#define _H_CDF_
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
--- libmagic.orig/cdf_time.c Thu Jun 21 00:18:33 2012
-+++ libmagic/cdf_time.c Wed Aug 27 12:35:45 2014
++++ libmagic/cdf_time.c Sun Nov 9 19:16:18 2014
@@ -96,7 +96,7 @@
}
static const char *ref = "Sat Apr 23 01:30:00 1977";
diff -u libmagic.orig/compress.c libmagic/compress.c
--- libmagic.orig/compress.c Sun Jan 5 16:55:21 2014
-+++ libmagic/compress.c Wed Aug 27 12:35:45 2014
++++ libmagic/compress.c Sun Nov 9 19:16:18 2014
@@ -32,6 +32,7 @@
* uncompress(method, old, n, newch) - uncompress old into new,
* using method, return sizeof new
+#endif /* if PHP_FILEINFO_UNCOMPRESS */
diff -u libmagic.orig/elfclass.h libmagic/elfclass.h
--- libmagic.orig/elfclass.h Mon Feb 18 19:33:14 2013
-+++ libmagic/elfclass.h Wed Aug 27 12:35:45 2014
++++ libmagic/elfclass.h Sun Nov 9 19:16:18 2014
@@ -37,7 +37,7 @@
case ET_CORE:
flags |= FLAGS_IS_CORE;
fsize, &flags, elf_getu16(swap, elfhdr.e_machine),
diff -u libmagic.orig/file.h libmagic/file.h
--- libmagic.orig/file.h Thu Feb 13 00:20:53 2014
-+++ libmagic/file.h Wed Aug 27 12:35:45 2014
++++ libmagic/file.h Wed Dec 10 12:00:53 2014
@@ -33,11 +33,9 @@
#ifndef __file_h__
#define __file_h__
((t) == FILE_STRING || \
(t) == FILE_PSTRING || \
(t) == FILE_BESTRING16 || \
-@@ -405,28 +407,23 @@
+@@ -405,28 +407,21 @@
/* Type for Unicode characters */
typedef unsigned long unichar;
- __attribute__((__format__(__printf__, 2, 3)));
+protected int file_printf(struct magic_set *, const char *, ...);
protected int file_reset(struct magic_set *);
- protected int file_tryelf(struct magic_set *, int, const unsigned char *,
- size_t);
+-protected int file_tryelf(struct magic_set *, int, const unsigned char *,
+- size_t);
protected int file_trycdf(struct magic_set *, int, const unsigned char *,
size_t);
-#if HAVE_FORK
protected int file_zmagic(struct magic_set *, int, const char *,
const unsigned char *, size_t);
#endif
-@@ -444,16 +441,13 @@
+@@ -444,16 +439,13 @@
protected int file_magicfind(struct magic_set *, const char *, struct mlist *);
protected uint64_t file_signextend(struct magic_set *, struct magic *,
uint64_t);
protected void file_showstr(FILE *, const char *, size_t);
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
-@@ -463,16 +457,14 @@
+@@ -463,16 +455,14 @@
size_t *);
protected size_t file_pstring_length_size(const struct magic *);
protected size_t file_pstring_get_length(const struct magic *, const char *);
#ifndef HAVE_STRERROR
extern int sys_nerr;
-@@ -485,20 +477,10 @@
+@@ -485,20 +475,10 @@
#define strtoul(a, b, c) strtol(a, b, c)
#endif
size_t strlcat(char *, const char *, size_t);
#endif
#ifndef HAVE_STRCASESTR
-@@ -535,6 +517,14 @@
+@@ -535,6 +515,14 @@
#endif
#else
#define FILE_RCSID(id)
#endif /* __file_h__ */
diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
--- libmagic.orig/fsmagic.c Sun Dec 1 20:22:13 2013
-+++ libmagic/fsmagic.c Wed Aug 27 12:35:45 2014
++++ libmagic/fsmagic.c Thu Dec 18 10:09:03 2014
@@ -59,27 +59,21 @@
# define minor(dev) ((dev) & 0xff)
#endif
private int
handle_mime(struct magic_set *ms, int mime, const char *str)
{
-@@ -96,42 +90,39 @@
+@@ -96,42 +90,38 @@
}
protected int
- ssize_t nch;
- struct stat tstatbuf;
-#endif
-+
+
if (ms->flags & MAGIC_APPLE)
return 0;
- if (fn == NULL)
}
ret = 1;
-@@ -154,30 +145,24 @@
+@@ -154,30 +144,24 @@
}
switch (sb->st_mode & S_IFMT) {
if (file_printf(ms, "%scharacter special (%d/%d/%d)",
COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev)) == -1)
-@@ -192,44 +177,11 @@
+@@ -192,44 +176,11 @@
if (file_printf(ms, "%scharacter special", COMMA) == -1)
return -1;
#endif
#ifdef S_IFIFO
case S_IFIFO:
if((ms->flags & MAGIC_DEVICES) != 0)
-@@ -252,79 +204,14 @@
+@@ -252,79 +203,14 @@
#endif
#ifdef S_IFLNK
case S_IFLNK:
#ifdef S_IFSOCK
#ifndef __COHERENT__
case S_IFSOCK:
-@@ -348,15 +235,15 @@
+@@ -348,15 +234,15 @@
* size for raw disk partitions. (If the block special device
* really has zero length, the fact that it is empty will be
* detected and reported correctly when we read the file.)
ret = 0;
break;
-@@ -366,9 +253,5 @@
+@@ -366,9 +252,5 @@
/*NOTREACHED*/
}
}
diff -u libmagic.orig/funcs.c libmagic/funcs.c
--- libmagic.orig/funcs.c Thu Feb 13 00:20:53 2014
-+++ libmagic/funcs.c Sat Aug 30 10:39:10 2014
++++ libmagic/funcs.c Thu Dec 18 10:09:03 2014
@@ -27,7 +27,7 @@
#include "file.h"
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "zmagic %d\n", m);
goto done_encoding;
-@@ -221,12 +219,17 @@
+@@ -221,12 +219,16 @@
}
/* Check if we have a CDF file */
- goto done;
+ if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
+ php_socket_t fd;
-+ + if (stream && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&fd, 0)) {
++ if (stream && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&fd, 0)) {
+ if ((m = file_trycdf(ms, fd, ubuf, nb)) != 0) {
+ if ((ms->flags & MAGIC_DEBUG) != 0)
+ (void)fprintf(stderr, "cdf %d\n", m);
/* try soft magic tests */
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
-@@ -268,7 +271,7 @@
+@@ -268,7 +270,7 @@
if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
if (looks_text == 0)
if ((m = file_ascmagic_with_encoding( ms, ubuf,
!= 0) {
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr,
-@@ -300,7 +303,6 @@
+@@ -300,7 +302,6 @@
return m;
}
protected int
file_reset(struct magic_set *ms)
-@@ -310,11 +312,11 @@
+@@ -310,11 +311,11 @@
return -1;
}
if (ms->o.buf) {
ms->o.pbuf = NULL;
}
ms->event_flags &= ~EVENT_HAD_ERR;
-@@ -333,7 +335,7 @@
+@@ -333,7 +334,7 @@
protected const char *
file_getbuffer(struct magic_set *ms)
{
size_t psize, len;
if (ms->event_flags & EVENT_HAD_ERR)
-@@ -348,15 +350,13 @@
+@@ -348,15 +349,13 @@
/* * 4 is for octal representation, + 1 is for NUL */
len = strlen(ms->o.buf);
if (len > (SIZE_MAX - 1) / 4) {
#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
{
-@@ -416,8 +416,8 @@
+@@ -416,8 +415,8 @@
if (level >= ms->c.len) {
len = (ms->c.len += 20) * sizeof(*ms->c.li);
ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
if (ms->c.li == NULL) {
file_oomem(ms, len);
return -1;
-@@ -437,32 +437,42 @@
+@@ -437,32 +436,41 @@
return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
}
+ zend_string *res;
+ zval repl;
+ int rep_cnt = 0;
-+
+
(void)setlocale(LC_CTYPE, "C");
- rc = regcomp(&rx, pat, REG_EXTENDED);
- if (rc) {
}
diff -u libmagic.orig/magic.c libmagic/magic.c
--- libmagic.orig/magic.c Sun Dec 1 20:22:13 2013
-+++ libmagic/magic.c Wed Aug 27 20:49:37 2014
++++ libmagic/magic.c Thu Dec 18 10:09:03 2014
@@ -25,11 +25,6 @@
* SUCH DAMAGE.
*/
}
/*
-@@ -332,31 +334,42 @@
+@@ -332,31 +334,41 @@
{
if (ms == NULL)
return NULL;
- int ispipe = 0;
- off_t pos = (off_t)-1;
+ int no_in_stream = 0;
-++
++
+ if (!inname && !stream) {
+ return NULL;
+ }
case -1: /* error */
goto done;
case 0: /* nothing found */
-@@ -366,74 +379,44 @@
+@@ -366,74 +378,44 @@
goto done;
}
return rv == 0 ? file_getbuffer(ms) : NULL;
}
-@@ -447,14 +430,13 @@
+@@ -447,14 +429,13 @@
return NULL;
/*
* The main work is done here!
public const char *
magic_error(struct magic_set *ms)
diff -u libmagic.orig/magic.h libmagic/magic.h
---- libmagic.orig/magic.h Wed Feb 19 10:53:11 2014
-+++ libmagic/magic.h Wed Aug 27 12:35:45 2014
+--- libmagic.orig/magic.h Tue Feb 11 16:30:44 2014
++++ libmagic/magic.h Sun Nov 9 19:16:18 2014
+@@ -75,7 +75,7 @@
+ #define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
+ #define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
+
+-#define MAGIC_VERSION 516 /* This implementation */
++#define MAGIC_VERSION 517 /* This implementation */
+
+
+ #ifdef __cplusplus
@@ -88,6 +88,7 @@
const char *magic_getpath(const char *, int);
diff -u libmagic.orig/print.c libmagic/print.c
--- libmagic.orig/print.c Tue Feb 26 19:25:00 2013
-+++ libmagic/print.c Wed Aug 27 12:35:45 2014
++++ libmagic/print.c Tue Dec 30 19:41:55 2014
@@ -28,13 +28,17 @@
/*
* print.c - debugging printout routines
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
-@@ -43,188 +47,28 @@
+@@ -43,188 +47,30 @@
#endif
#include <time.h>
file_magwarn(struct magic_set *ms, const char *f, ...)
{
va_list va;
-+ char *expanded_format;
-+
++ char *expanded_format = NULL;
++ int expanded_len;
+
- /* cuz we use stdout for most, stderr here */
- (void) fflush(stdout);
-
- (void) fprintf(stderr, "Warning: ");
va_start(va, f);
- (void) vfprintf(stderr, f, va);
-+ if (vasprintf(&expanded_format, f, va)); /* silence */
++ expanded_len = vasprintf(&expanded_format, f, va);
va_end(va);
- (void) fputc('\n', stderr);
+
-+ php_error_docref(NULL, E_NOTICE, "Warning: %s", expanded_format);
++ if (expanded_len >= 0 && expanded_format) {
++ php_error_docref(NULL, E_NOTICE, "Warning: %s", expanded_format);
+
-+ free(expanded_format);
++ free(expanded_format);
++ }
}
protected const char *
-@@ -235,7 +79,7 @@
+@@ -235,7 +81,7 @@
struct tm *tm;
if (flags & FILE_T_WINDOWS) {
}
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
--- libmagic.orig/readcdf.c Tue Jan 7 04:13:42 2014
-+++ libmagic/readcdf.c Wed Oct 22 17:56:13 2014
++++ libmagic/readcdf.c Sun Nov 9 19:16:18 2014
@@ -26,11 +26,15 @@
#include "file.h"
if (str != NULL) {
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
--- libmagic.orig/softmagic.c Thu Feb 13 00:20:53 2014
-+++ libmagic/softmagic.c Fri Sep 19 16:29:55 2014
++++ libmagic/softmagic.c Thu Dec 18 10:09:03 2014
@@ -50,6 +50,11 @@
#include <locale.h>
#endif
m = &magic[magindex];
ms->line = m->lineno; /* for messages */
-@@ -350,46 +356,27 @@
+@@ -350,46 +356,26 @@
private int
check_fmt(struct magic_set *ms, struct magic *m)
{
+ int re_options, rv = -1;
+ pcre_extra *re_extra;
+ zend_string *pattern;
-++
++
if (strchr(m->desc, '%') == NULL)
return 0;
private int32_t
mprint(struct magic_set *ms, struct magic *m)
{
-@@ -618,13 +605,13 @@
+@@ -618,13 +604,13 @@
char *cp;
int rval;
if (rval == -1)
return -1;
-@@ -870,16 +857,16 @@
+@@ -870,16 +856,16 @@
if (m->num_mask) \
switch (m->mask_op & FILE_OPS_MASK) { \
case FILE_OPADD: \
break; \
} \
-@@ -931,10 +918,18 @@
+@@ -931,10 +917,18 @@
return 1;
}
case FILE_PSTRING: {
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
-@@ -1046,7 +1041,7 @@
+@@ -1046,7 +1040,7 @@
private int
mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
{
/*
* Note: FILE_SEARCH and FILE_REGEX do not actually copy
-@@ -1066,15 +1061,24 @@
+@@ -1066,15 +1060,24 @@
const char *last; /* end of search region */
const char *buf; /* start of search region */
const char *end;
/* mget() guarantees buf <= last */
for (lines = linecnt, b = buf; lines && b < end &&
((b = CAST(const char *,
-@@ -1087,7 +1091,7 @@
+@@ -1087,7 +1090,7 @@
b++;
}
if (lines)
ms->search.s = buf;
ms->search.s_len = last - buf;
-@@ -1158,7 +1162,6 @@
+@@ -1158,7 +1161,6 @@
int *need_separator, int *returnval)
{
uint32_t soffset, offset = ms->offset;
int rv, oneed_separator, in_type;
char *sbuf, *rbuf;
union VALUETYPE *p = &ms->ms_value;
-@@ -1170,17 +1173,13 @@
+@@ -1170,17 +1172,13 @@
}
if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
}
if (m->flag & INDIR) {
-@@ -1672,16 +1671,13 @@
+@@ -1672,16 +1670,13 @@
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "indirect +offs=%u\n", offset);
}
}
}
-@@ -1755,11 +1751,21 @@
+@@ -1755,11 +1750,21 @@
ms->offset = soffset;
if (rv == 1) {
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
}
return rv;
-@@ -1875,6 +1881,41 @@
+@@ -1875,6 +1880,41 @@
return file_strncmp(a, b, len, flags);
}
private int
magiccheck(struct magic_set *ms, struct magic *m)
{
-@@ -2035,63 +2076,112 @@
+@@ -2035,63 +2075,111 @@
break;
}
case FILE_REGEX: {
+ zval pattern;
+ int options = 0;
+ pcre_cache_entry *pce;
-+ +
++
+ options |= PCRE_MULTILINE;
+
+ if (m->str_flags & STRING_IGNORE_CASE) {
case FILE_INDIRECT:
diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c
--- libmagic.orig/strcasestr.c Thu Dec 5 17:57:50 2013
-+++ libmagic/strcasestr.c Wed Aug 27 12:35:45 2014
++++ libmagic/strcasestr.c Sun Nov 9 19:16:18 2014
@@ -37,6 +37,8 @@
__RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <ctype.h>
#include <string.h>
-diff --git libmagic/file.h libmagic/file.h
-index 0a5c19c..2b2405f 100644
---- libmagic/file.h
-+++ libmagic/file.h
-@@ -419,8 +419,6 @@ protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
- protected int file_replace(struct magic_set *, const char *, const char *);
- protected int file_printf(struct magic_set *, const char *, ...);
- protected int file_reset(struct magic_set *);
--protected int file_tryelf(struct magic_set *, int, const unsigned char *,
-- size_t);
- protected int file_trycdf(struct magic_set *, int, const unsigned char *,
- size_t);
- #ifdef PHP_FILEINFO_UNCOMPRESS