From: Anatol Belski Date: Tue, 18 Feb 2014 18:08:16 +0000 (+0100) Subject: updated libmagic.patch X-Git-Tag: php-5.4.27RC1~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a289b37f48f730bbb46159f2fab2bbc95d4c7d64;p=php updated libmagic.patch --- diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 97e771e920..d7fc532904 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c ---- libmagic.orig/apprentice.c 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/apprentice.c 2013-04-27 13:53:32.175250261 +0200 +--- libmagic.orig/apprentice.c Thu Mar 21 18:45:14 2013 ++++ libmagic/apprentice.c Fri May 3 15:19:35 2013 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -830,8 +830,8 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c m->str_flags = swap4(m->str_flags); } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c ---- libmagic.orig/ascmagic.c 2012-10-31 18:03:01.000000000 +0100 -+++ libmagic/ascmagic.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/ascmagic.c Wed Oct 31 18:03:01 2012 ++++ libmagic/ascmagic.c Tue Feb 18 18:44:17 2014 @@ -139,7 +139,7 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -841,6 +841,15 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c file_oomem(ms, mlen); goto done; } +@@ -147,7 +147,7 @@ + == 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; + } + @@ -211,6 +211,7 @@ case 0: if (file_printf(ms, ", ") == -1) @@ -860,8 +869,8 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } diff -u libmagic.orig/cdf.c libmagic/cdf.c ---- libmagic.orig/cdf.c 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/cdf.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/cdf.c Thu Mar 21 18:45:14 2013 ++++ libmagic/cdf.c Sun Apr 7 22:30:22 2013 @@ -43,7 +43,17 @@ #include #endif @@ -923,8 +932,8 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c (void)fprintf(stderr, "timestamp %s\n", buf); } else { diff -u libmagic.orig/cdf.h libmagic/cdf.h ---- libmagic.orig/cdf.h 2012-10-31 18:03:01.000000000 +0100 -+++ libmagic/cdf.h 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/cdf.h Wed Oct 31 18:03:01 2012 ++++ libmagic/cdf.h Sun Apr 7 22:30:22 2013 @@ -35,10 +35,12 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -966,8 +975,8 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h void cdf_swap_header(cdf_header_t *); void cdf_unpack_header(cdf_header_t *, char *); diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c ---- libmagic.orig/cdf_time.c 2012-10-31 18:03:01.000000000 +0100 -+++ libmagic/cdf_time.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/cdf_time.c Wed Oct 31 18:03:01 2012 ++++ libmagic/cdf_time.c Sun Apr 7 22:30:22 2013 @@ -96,7 +96,7 @@ } @@ -1026,8 +1035,8 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL; static const char *ref = "Sat Apr 23 01:30:00 1977"; diff -u libmagic.orig/compress.c libmagic/compress.c ---- libmagic.orig/compress.c 2013-01-06 21:35:43.000000000 +0100 -+++ libmagic/compress.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/compress.c Sun Jan 6 21:35:43 2013 ++++ libmagic/compress.c Sun Apr 7 22:30:22 2013 @@ -32,6 +32,7 @@ * uncompress(method, old, n, newch) - uncompress old into new, * using method, return sizeof new @@ -1189,8 +1198,8 @@ diff -u libmagic.orig/compress.c libmagic/compress.c -#endif +#endif /* if PHP_FILEINFO_UNCOMPRESS */ diff -u libmagic.orig/file.h libmagic/file.h ---- libmagic.orig/file.h 2013-02-18 16:40:59.000000000 +0100 -+++ libmagic/file.h 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/file.h Mon Feb 18 16:40:59 2013 ++++ libmagic/file.h Tue Feb 18 18:44:17 2014 @@ -33,11 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1303,7 +1312,13 @@ diff -u libmagic.orig/file.h libmagic/file.h protected int file_zmagic(struct magic_set *, int, const char *, const unsigned char *, size_t); #endif -@@ -443,16 +442,13 @@ +@@ -438,21 +437,18 @@ + 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 *, uint64_t); @@ -1377,22 +1392,24 @@ diff -u libmagic.orig/file.h libmagic/file.h #if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK) #define QUICK -@@ -533,4 +511,12 @@ - #define FILE_RCSID(id) +@@ -531,6 +509,14 @@ #endif - + #else + #define FILE_RCSID(id) ++#endif ++ +#ifdef PHP_WIN32 +#define FINFO_LSEEK_FUNC _lseek +#define FINFO_READ_FUNC _read +#else +#define FINFO_LSEEK_FUNC lseek +#define FINFO_READ_FUNC read -+#endif -+ + #endif + #endif /* __file_h__ */ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c ---- libmagic.orig/fsmagic.c 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/fsmagic.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/fsmagic.c Thu Mar 21 18:45:14 2013 ++++ libmagic/fsmagic.c Sun Apr 7 22:30:22 2013 @@ -59,27 +59,21 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -1758,8 +1775,8 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c return ret; } diff -u libmagic.orig/funcs.c libmagic/funcs.c ---- libmagic.orig/funcs.c 2012-10-31 18:03:01.000000000 +0100 -+++ libmagic/funcs.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/funcs.c Wed Oct 31 18:03:01 2012 ++++ libmagic/funcs.c Tue Feb 18 18:44:17 2014 @@ -41,52 +41,42 @@ #if defined(HAVE_WCTYPE_H) #include @@ -1896,7 +1913,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c if ((ms->flags & MAGIC_DEBUG) != 0) (void)fprintf(stderr, "zmagic %d\n", m); goto done; -@@ -219,12 +221,17 @@ +@@ -219,16 +221,21 @@ } /* Check if we have a CDF file */ @@ -1919,6 +1936,11 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c /* 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); @@ -296,7 +303,6 @@ return m; @@ -2047,8 +2069,8 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c } + diff -u libmagic.orig/magic.c libmagic/magic.c ---- libmagic.orig/magic.c 2013-01-11 17:43:09.000000000 +0100 -+++ libmagic/magic.c 2013-04-27 13:53:32.175250261 +0200 +--- libmagic.orig/magic.c Fri Jan 11 17:43:09 2013 ++++ libmagic/magic.c Fri May 3 15:19:35 2013 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -2391,8 +2413,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2013-03-21 18:52:42.000000000 +0100 -+++ libmagic/magic.h 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/magic.h Thu Mar 21 18:52:42 2013 ++++ libmagic/magic.h Sun Apr 7 22:30:22 2013 @@ -87,6 +87,7 @@ const char *magic_getpath(const char *, int); @@ -2410,15 +2432,15 @@ diff -u libmagic.orig/magic.h libmagic/magic.h int magic_errno(magic_t); diff -u libmagic.orig/print.c libmagic/print.c ---- libmagic.orig/print.c 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/print.c 2013-04-27 13:53:32.175250261 +0200 -@@ -28,13 +28,17 @@ - /* +--- libmagic.orig/print.c Thu Mar 21 18:45:14 2013 ++++ libmagic/print.c Mon Dec 16 23:09:24 2013 +@@ -29,12 +29,17 @@ * print.c - debugging printout routines */ + +#define _GNU_SOURCE +#include "php.h" - ++ #include "file.h" +#include "cdf.h" @@ -2430,7 +2452,7 @@ diff -u libmagic.orig/print.c libmagic/print.c #include #include #include -@@ -43,188 +47,28 @@ +@@ -43,188 +48,28 @@ #endif #include @@ -2631,7 +2653,7 @@ diff -u libmagic.orig/print.c libmagic/print.c } protected const char * -@@ -235,7 +79,7 @@ +@@ -235,7 +80,7 @@ struct tm *tm; if (flags & FILE_T_WINDOWS) { @@ -2641,8 +2663,8 @@ diff -u libmagic.orig/print.c libmagic/print.c t = ts.tv_sec; } diff -u libmagic.orig/readcdf.c libmagic/readcdf.c ---- libmagic.orig/readcdf.c 2012-10-31 18:03:01.000000000 +0100 -+++ libmagic/readcdf.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/readcdf.c Wed Oct 31 18:03:01 2012 ++++ libmagic/readcdf.c Sun Apr 7 22:30:22 2013 @@ -30,7 +30,11 @@ #endif @@ -2704,8 +2726,8 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (file_printf(ms, "application/CDFV2-corrupt") == -1) return -1; diff -u libmagic.orig/readelf.c libmagic/readelf.c ---- libmagic.orig/readelf.c 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/readelf.c 2013-04-08 15:42:57.328298809 +0200 +--- libmagic.orig/readelf.c Thu Mar 21 18:45:14 2013 ++++ libmagic/readelf.c Sun Apr 7 22:30:22 2013 @@ -48,8 +48,8 @@ private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t, off_t, int *, int); @@ -2956,8 +2978,8 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (fstat(fd, &st) == -1) { diff -u libmagic.orig/readelf.h libmagic/readelf.h ---- libmagic.orig/readelf.h 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/readelf.h 2013-03-31 16:57:18.499744030 +0200 +--- libmagic.orig/readelf.h Thu Mar 21 18:45:14 2013 ++++ libmagic/readelf.h Wed Mar 28 15:35:26 2012 @@ -44,9 +44,17 @@ typedef uint32_t Elf32_Word; typedef uint8_t Elf32_Char; @@ -2977,8 +2999,8 @@ diff -u libmagic.orig/readelf.h libmagic/readelf.h typedef uint32_t Elf64_Word; typedef uint8_t Elf64_Char; diff -u libmagic.orig/softmagic.c libmagic/softmagic.c ---- libmagic.orig/softmagic.c 2013-03-21 18:45:14.000000000 +0100 -+++ libmagic/softmagic.c 2013-05-14 11:00:07.044745939 +0200 +--- libmagic.orig/softmagic.c Thu Mar 21 18:45:14 2013 ++++ libmagic/softmagic.c Tue Feb 18 18:44:17 2014 @@ -41,6 +41,11 @@ #include #include @@ -2991,6 +3013,22 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int match(struct magic_set *, struct magic *, uint32_t, const unsigned char *, size_t, size_t, int, int, int, int, int *, int *, +@@ -69,13 +74,13 @@ + /*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; + 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; + @@ -132,7 +137,7 @@ struct magic *m = &magic[magindex]; @@ -3113,7 +3151,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } if (m->flag & INDIR) { -@@ -1644,9 +1624,6 @@ +@@ -1644,16 +1624,13 @@ if ((ms->flags & MAGIC_DEBUG) != 0) { mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE)); @@ -3123,7 +3161,32 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } } -@@ -1717,12 +1694,12 @@ + /* Verify we have enough data to match magic type */ + switch (m->type) { + case FILE_BYTE: +- if (nbytes < (offset + 1)) /* should alway be true */ ++ if (nbytes < (offset + 1)) /* should always be true */ + return 0; + break; + +@@ -1703,6 +1680,8 @@ + break; + + case FILE_INDIRECT: ++ if (offset == 0) ++ return 0; + if (nbytes < offset) + return 0; + sbuf = ms->o.buf; +@@ -1710,19 +1689,19 @@ + 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; ms->o.buf = sbuf; ms->offset = soffset; if (rv == 1) { @@ -3139,7 +3202,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } return rv; -@@ -1837,6 +1814,42 @@ +@@ -1837,6 +1816,42 @@ return file_strncmp(a, b, len, flags); } @@ -3182,7 +3245,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -1996,69 +2009,157 @@ +@@ -1996,69 +2011,157 @@ break; } case FILE_REGEX: {