]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.1'
authorXinchen Hui <laruence@gmail.com>
Mon, 10 Apr 2017 03:47:38 +0000 (11:47 +0800)
committerXinchen Hui <laruence@gmail.com>
Mon, 10 Apr 2017 03:47:38 +0000 (11:47 +0800)
* PHP-7.1:
  Update NEWS
  Fixed bug #74379 (syntax error compile error in libmagic/apprentice.c)
  Missed NEWS

Conflicts:
ext/fileinfo/libmagic.patch

1  2 
ext/fileinfo/libmagic.patch
ext/fileinfo/libmagic/apprentice.c

index 679a23192bc53c69ccf44f61dc3bd26bc1a3dd9a,cdacce7f49295513ac936c0a66fe0251a26c536e..b6c93cab8821c166b81cddcb9324ab6e094da277
@@@ -1,6 -1,6 +1,6 @@@
  diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
- --- libmagic.orig/apprentice.c        2016-11-23 17:08:22.955687700 +0100
- +++ libmagic/apprentice.c     2016-11-24 16:55:16.299587400 +0100
 ---- libmagic.orig/apprentice.c        2017-04-10 11:41:09.731268025 +0800
 -+++ libmagic/apprentice.c     2017-04-10 11:43:17.272811417 +0800
++--- libmagic.orig/apprentice.c        2017-04-10 11:46:03.857163505 +0800
+++++ libmagic/apprentice.c     2017-04-10 11:46:16.375492995 +0800
  @@ -29,6 +29,8 @@
    * apprentice - make one pass through /etc/magic, learning its secrets.
    */
   
   #ifndef SSIZE_MAX
   #define MAXMAGIC_SIZE        ((ssize_t)0x7fffffff)
- @@ -170,38 +175,7 @@
+ @@ -75,6 +80,10 @@
+  #endif
+  #endif
+  
+ +#ifndef offsetof
+ +#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
+ +#endif
+ +
+  #ifndef MAP_FAILED
+  #define MAP_FAILED (void *) -1
+  #endif
 -@@ -168,38 +177,7 @@
++@@ -170,38 +179,7 @@
        { NULL, 0, NULL }
   };
   
   
   struct type_tbl_s {
        const char name[16];
- @@ -285,6 +259,10 @@
 -@@ -281,6 +259,10 @@
++@@ -285,6 +263,10 @@
   # undef XX
   # undef XX_NULL
   
   private int
   get_type(const struct type_tbl_s *tbl, const char *l, const char **t)
   {
- @@ -409,7 +387,7 @@
 -@@ -405,7 +387,7 @@
++@@ -409,7 +391,7 @@
        struct mlist *ml;
   
 -      mlp->map = idx == 0 ? map : NULL;
 +      mlp->map = NULL;
  -     if ((ml = CAST(struct mlist *, malloc(sizeof(*ml)))) == NULL)
  +     if ((ml = CAST(struct mlist *, emalloc(sizeof(*ml)))) == NULL)
                return -1;
   
 -      ml->map = NULL;
 -@@ -426,10 +408,8 @@
 +      ml->map = idx == 0 ? map : NULL;
- @@ -430,10 +408,8 @@
++@@ -430,10 +412,8 @@
   apprentice_1(struct magic_set *ms, const char *fn, int action)
   {
        struct magic_map *map;
   
        if (magicsize != FILE_MAGICSIZE) {
                file_error(ms, 0, "magic element size %lu != %lu",
- @@ -449,14 +425,15 @@
 -@@ -445,12 +425,13 @@
++@@ -449,14 +429,15 @@
                return apprentice_compile(ms, map, fn);
        }
   
                if (map == NULL)
                        return -1;
        }
- @@ -478,9 +455,6 @@
 -@@ -458,7 +439,8 @@
 -      for (i = 0; i < MAGIC_SETS; i++) {
 -              if (add_mlist(ms->mlist[i], map, i) == -1) {
 -                      file_oomem(ms, sizeof(*ml));
 --                     goto fail;
 -+                     apprentice_unmap(map);
 -+                     return -1;
 -              }
 -      }
 - 
 -@@ -472,15 +454,6 @@
++@@ -478,9 +459,6 @@
                }
        }
        return 0;
   }
   
   protected void
- @@ -491,10 +465,16 @@
 -@@ -491,10 +464,16 @@
++@@ -491,10 +469,16 @@
                return;
        for (i = 0; i < MAGIC_SETS; i++)
                mlist_free(ms->mlist[i]);
   }
   
   protected struct magic_set *
- @@ -503,7 +483,7 @@
 -@@ -503,7 +482,7 @@
++@@ -503,7 +487,7 @@
        struct magic_set *ms;
        size_t i, len;
   
            sizeof(struct magic_set)))) == NULL)
                return NULL;
   
- @@ -515,7 +495,7 @@
 -@@ -515,7 +494,7 @@
++@@ -515,7 +499,7 @@
        ms->o.buf = ms->o.pbuf = NULL;
        len = (ms->c.len = 10) * sizeof(*ms->c.li);
   
                goto free;
   
        ms->event_flags = 0;
- @@ -533,46 +513,35 @@
 -@@ -531,7 +510,7 @@
 -      ms->elf_notes_max = FILE_ELF_NOTES_MAX;
++@@ -533,46 +517,35 @@
 +      ms->bytes_max = FILE_BYTES_MAX;
        return ms;
   free:
  -     free(ms);
                return NULL;
        }
        mlist->next = mlist->prev = mlist;
- @@ -591,61 +560,12 @@
 -@@ -582,61 +557,12 @@
++@@ -591,61 +564,12 @@
        for (ml = mlist->next; (next = ml->next) != NULL; ml = next) {
                if (ml->map)
 -                      apprentice_unmap(ml->map);
 +                      apprentice_unmap(CAST(struct magic_map *, ml->map));
  -             free(ml);
  +             efree(ml);
                if (ml == mlist)
   /* const char *fn: list of magic files and directories */
   protected int
   file_apprentice(struct magic_set *ms, const char *fn, int action)
- @@ -657,12 +577,28 @@
 -@@ -648,12 +574,28 @@
++@@ -657,12 +581,28 @@
        if (ms->mlist[0] != NULL)
                file_reset(ms);
   
                file_oomem(ms, strlen(fn));
                return -1;
        }
- @@ -675,7 +611,7 @@
 -@@ -666,7 +608,7 @@
++@@ -675,7 +615,7 @@
                                mlist_free(ms->mlist[i]);
                                ms->mlist[i] = NULL;
                        }
                        return -1;
                }
        }
- @@ -692,7 +628,7 @@
 -@@ -683,7 +625,7 @@
++@@ -692,7 +632,7 @@
                fn = p;
        }
   
   
        if (errs == -1) {
                for (i = 0; i < MAGIC_SETS; i++) {
- @@ -1076,7 +1012,7 @@
 -@@ -1062,7 +1004,7 @@
++@@ -1076,7 +1016,7 @@
   
                mset[i].max += ALLOC_INCR;
                if ((mp = CAST(struct magic_entry *,
                    NULL) {
                        file_oomem(ms, sizeof(*mp) * mset[i].max);
                        return -1;
- @@ -1097,13 +1033,19 @@
 -@@ -1083,13 +1025,19 @@
++@@ -1097,13 +1037,19 @@
   load_1(struct magic_set *ms, int action, const char *fn, int *errs,
      struct magic_entry_set *mset)
   {
                if (errno != ENOENT)
                        file_error(ms, errno, "cannot read magic file `%s'",
                                   fn);
- @@ -1113,8 +1055,7 @@
 -@@ -1099,8 +1047,7 @@
++@@ -1113,8 +1059,7 @@
   
        memset(&me, 0, sizeof(me));
        /* read and parse this file */
                if (len == 0) /* null line, garbage, etc */
                        continue;
                if (line[len - 1] == '\n') {
- @@ -1172,8 +1113,8 @@
 -@@ -1158,8 +1105,8 @@
++@@ -1172,8 +1117,8 @@
        }
        if (me.mp)
                (void)addentry(ms, &me, mset);
   }
   
   /*
- @@ -1252,7 +1193,7 @@
 -@@ -1238,7 +1185,7 @@
++@@ -1252,7 +1197,7 @@
                mentrycount += me[i].cont_count;
   
        slen = sizeof(**ma) * mentrycount;
                file_oomem(ms, slen);
                return -1;
        }
- @@ -1274,8 +1215,8 @@
 -@@ -1260,8 +1207,8 @@
++@@ -1274,8 +1219,8 @@
        if (me == NULL)
                return;
        for (i = 0; i < nme; i++)
   }
   
   private struct magic_map *
- @@ -1284,18 +1225,19 @@
 -@@ -1270,18 +1217,19 @@
++@@ -1284,18 +1229,19 @@
        int errs = 0;
        uint32_t i, j;
        size_t files = 0, maxfiles = 0;
        {
                file_oomem(ms, sizeof(*map));
                return NULL;
- @@ -1307,22 +1249,26 @@
 -@@ -1292,22 +1240,26 @@
++@@ -1307,22 +1253,26 @@
                (void)fprintf(stderr, "%s\n", usg_hdr);
   
        /* load directory or file */
                                continue;
                        }
                        if (files >= maxfiles) {
- @@ -1330,23 +1276,22 @@
 -@@ -1315,23 +1267,22 @@
++@@ -1330,23 +1280,22 @@
                                maxfiles = (maxfiles + 1) * 2;
                                mlen = maxfiles * sizeof(*filearr);
                                if ((filearr = CAST(char **,
        } else
                load_1(ms, action, fn, &errs, mset);
        if (errs)
- @@ -1813,7 +1758,7 @@
 -@@ -1796,7 +1747,7 @@
++@@ -1813,7 +1762,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;
- @@ -1828,7 +1773,7 @@
 -@@ -1811,7 +1762,7 @@
++@@ -1828,7 +1777,7 @@
                static const size_t len = sizeof(*m) * ALLOC_CHUNK;
                if (me->mp != NULL)
                        return 1;
                        file_oomem(ms, len);
                        return -1;
                }
- @@ -2032,7 +1977,7 @@
 -@@ -1984,7 +1935,7 @@
 -                              m->type = get_standard_integer_type(l, &l);
 -                      else if (*l == 's' && !isalpha((unsigned char)l[1])) {
 -                              m->type = FILE_STRING;
 --                             ++l;
 -+             ++l;
 -                      }
 -              }
 -      }
 -@@ -2005,7 +1956,7 @@
++@@ -2032,7 +1981,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");
- @@ -2041,7 +1986,7 @@
 -@@ -2014,7 +1965,7 @@
++@@ -2041,7 +1990,7 @@
        m->str_range = 0;
        m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0;
        if ((op = get_op(*l)) != -1) {
                        int r;
   
                        if (op != FILE_OPDIVIDE) {
- @@ -2146,11 +2091,6 @@
 -@@ -2119,11 +2070,6 @@
++@@ -2146,11 +2095,6 @@
                if (check_format(ms, m) == -1)
                        return -1;
        }
        m->mimetype[0] = '\0';          /* initialise MIME type to none */
        return 0;
   }
- @@ -2222,7 +2162,7 @@
 -@@ -2195,7 +2141,7 @@
++@@ -2222,7 +2166,7 @@
   
   private int
   parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line,
   {
        size_t i;
        const char *l = line;
- @@ -2304,7 +2244,7 @@
 -@@ -2264,7 +2210,7 @@
++@@ -2304,7 +2248,7 @@
        struct magic *m = &me->mp[0];
   
        return parse_extra(ms, me, line,
            sizeof(m->mimetype), "MIME", "+-/.", 1);
   }
   
- @@ -2578,14 +2518,18 @@
 -@@ -2517,14 +2463,18 @@
++@@ -2578,14 +2522,18 @@
                        return -1;
                }
                if (m->type == FILE_REGEX) {
                }
                return 0;
        case FILE_FLOAT:
- @@ -2924,79 +2868,145 @@
 -@@ -2854,68 +2804,144 @@
++@@ -2924,79 +2872,145 @@
   private struct magic_map *
   apprentice_map(struct magic_set *ms, const char *fn)
   {
                file_oomem(ms, sizeof(*map));
  -             goto error;
  +             return NULL;
+     }
      }
 - 
++-     map->type = MAP_TYPE_USER;      /* unspecified */
 ++
  +     if (fn == NULL) {
  +             map->p = (void *)&php_magic_database;
  +             goto internal_loaded;
  +     if (dbname) {
  +             efree(dbname);
  +     }
 -      return NULL;
 ++     return NULL;
   }
   
 -@@ -2942,7 +2968,7 @@
 + private int
- @@ -3022,7 +3032,7 @@
++@@ -3022,7 +3036,7 @@
                version = ptr[1];
        if (version != VERSIONNO) {
                file_error(ms, 0, "File %s supports only version %d magic "
                    VERSIONNO, dbname, version);
                return -1;
        }
- @@ -3063,7 +3073,6 @@
 -@@ -2983,7 +3009,6 @@
++@@ -3063,7 +3077,6 @@
   {
        static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS;
        static const size_t m = sizeof(**map->magic);
        size_t len;
        char *dbname;
        int rv = -1;
- @@ -3072,14 +3081,17 @@
 -@@ -2992,14 +3017,18 @@
++@@ -3072,14 +3085,17 @@
                struct magic m;
                uint32_t h[2 + MAGIC_SETS];
        } hdr;
                file_error(ms, errno, "cannot open `%s'", dbname);
                goto out;
        }
- @@ -3088,25 +3100,25 @@
 -@@ -3008,24 +3037,25 @@
++@@ -3088,25 +3104,25 @@
        hdr.h[1] = VERSIONNO;
        memcpy(hdr.h + 2, map->nmagic, nm);
   
        return rv;
   }
   
- @@ -3140,16 +3152,18 @@
 -@@ -3059,16 +3089,18 @@
++@@ -3140,16 +3156,18 @@
        q++;
        /* Compatibility with old code that looked in .mime */
        if (ms->flags & MAGIC_MIME) {
  +     spprintf(&buf, MAXPATHLEN, "%.*s%s", (int)(q - fn), fn, ext);
   
        /* Compatibility with old code that looked in .mime */
 -      if (strstr(p, ".mime") != NULL)
 -@@ -3158,7 +3190,7 @@
 +      if (strstr(fn, ".mime") != NULL)
- @@ -3239,7 +3253,7 @@
++@@ -3239,7 +3257,7 @@
        m->offset = swap4((uint32_t)m->offset);
        m->in_offset = swap4((uint32_t)m->in_offset);
        m->lineno = swap4((uint32_t)m->lineno);
                m->str_flags = swap4(m->str_flags);
        }
  diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
- --- libmagic.orig/ascmagic.c  2016-11-23 17:08:23.422184100 +0100
- +++ libmagic/ascmagic.c       2016-11-24 13:42:04.130245900 +0100
 ---- libmagic.orig/ascmagic.c  2017-04-10 11:41:09.737268025 +0800
 -+++ libmagic/ascmagic.c       2017-04-10 11:41:14.411268021 +0800
 -@@ -139,7 +139,7 @@
++--- libmagic.orig/ascmagic.c  2017-04-10 11:46:03.872171005 +0800
+++++ libmagic/ascmagic.c       2017-04-10 11:46:07.197493002 +0800
 +@@ -133,7 +133,7 @@
                /* malloc size is a conservative overestimate; could be
                   improved, or at least realloced after conversion. */
                mlen = ulen * 6;
        return rv;
   }
  diff -u libmagic.orig/cdf.c libmagic/cdf.c
- --- libmagic.orig/cdf.c       2016-11-23 17:08:24.328677300 +0100
- +++ libmagic/cdf.c    2016-11-24 13:42:04.138254700 +0100
 ---- libmagic.orig/cdf.c       2017-04-10 11:41:09.731268025 +0800
 -+++ libmagic/cdf.c    2017-04-10 11:41:14.411268021 +0800
 -@@ -35,7 +35,7 @@
 - #include "file.h"
 - 
 - #ifndef lint
 --FILE_RCSID("@(#)$File: cdf.c,v 1.75 2015/02/27 21:16:55 christos Exp $")
 -+FILE_RCSID("@(#)$File: cdf.c,v 1.73 2015/01/11 16:58:25 christos Exp $")
 - #endif
 - 
 - #include <assert.h>
++--- libmagic.orig/cdf.c       2017-04-10 11:46:03.857163505 +0800
+++++ libmagic/cdf.c    2017-04-10 11:46:07.197493002 +0800
  @@ -43,7 +43,17 @@
   #include <err.h>
   #endif
        if (argc < 2) {
                (void)fprintf(stderr, "Usage: %s <filename>\n", getprogname());
                return -1;
 -@@ -1491,8 +1496,8 @@
 -              else
 -                      cdf_dump_summary_info(&h, &scn);
 - #endif
 --             if (cdf_read_user_stream(&info, &h, &sat, &ssat, &sst,
 --                 &dir, "Catalog", &scn) == -1)
 -+             if (cdf_read_catalog(&info, &h, &sat, &ssat, &sst, &dir,
 -+                 &scn) == -1)
 -                      warn("Cannot read catalog");
 - #ifdef CDF_DEBUG
 -              else
  diff -u libmagic.orig/cdf.h libmagic/cdf.h
- --- libmagic.orig/cdf.h       2016-11-26 14:20:33.240401300 +0100
- +++ libmagic/cdf.h    2016-11-26 14:20:33.781858400 +0100
 ---- libmagic.orig/cdf.h       2017-04-10 11:41:09.737268025 +0800
 -+++ libmagic/cdf.h    2017-04-10 11:41:14.412268021 +0800
++--- libmagic.orig/cdf.h       2017-04-10 11:46:03.871170505 +0800
+++++ libmagic/cdf.h    2017-04-10 11:46:07.198493002 +0800
  @@ -35,10 +35,12 @@
   #ifndef _H_CDF_
   #define _H_CDF_
   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  2016-11-23 17:08:25.086670200 +0100
- +++ libmagic/cdf_time.c       2016-11-24 13:40:19.272464700 +0100
 ---- libmagic.orig/cdf_time.c  2017-04-10 11:41:09.737268025 +0800
 -+++ libmagic/cdf_time.c       2017-04-10 11:41:14.412268021 +0800
++--- libmagic.orig/cdf_time.c  2017-04-10 11:46:03.872171005 +0800
+++++ libmagic/cdf_time.c       2017-04-10 11:46:07.198493002 +0800
  @@ -96,7 +96,7 @@
   }
   
        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  2016-11-23 17:08:25.345167600 +0100
- +++ libmagic/compress.c       2017-01-05 23:15:53.219543000 +0100
 ---- libmagic.orig/compress.c  2017-04-10 11:41:09.732268025 +0800
 -+++ libmagic/compress.c       2017-04-10 11:41:14.412268021 +0800
 -@@ -32,10 +32,11 @@
 -  *   uncompress(method, old, n, newch) - uncompress old into new, 
 -  *                                       using method, return sizeof new
 -  */
 -+#include "config.h"
 - #include "file.h"
 - 
 - #ifndef lint
 --FILE_RCSID("@(#)$File: compress.c,v 1.78 2015/01/02 21:29:39 christos Exp $")
 -+FILE_RCSID("@(#)$File: compress.c,v 1.77 2014/12/12 16:33:01 christos Exp $")
++--- libmagic.orig/compress.c  2017-04-10 11:46:03.864167005 +0800
+++++ libmagic/compress.c       2017-04-10 11:46:07.198493002 +0800
 +@@ -45,15 +45,13 @@
   #endif
 - 
 - #include "magic.h"
 -@@ -51,7 +52,7 @@
 + #include <string.h>
 + #include <errno.h>
 +-#include <ctype.h>
 +-#include <stdarg.h>
 + #ifdef HAVE_SIGNAL_H
 + #include <signal.h>
 + # ifndef HAVE_SIG_T
   typedef void (*sig_t)(int);
   # endif /* HAVE_SIG_T */
   #endif 
   }
  -#endif
  +#endif /* if PHP_FILEINFO_UNCOMPRESS */
- --- libmagic.orig/der.c       2016-11-23 17:08:25.601237900 +0100
- +++ libmagic/der.c    2017-01-05 23:25:59.696458300 +0100
 +diff -u libmagic.orig/der.c libmagic/der.c
++--- libmagic.orig/der.c       2017-04-10 11:46:03.863166505 +0800
+++++ libmagic/der.c    2017-04-10 11:46:07.198493002 +0800
 +@@ -51,7 +51,9 @@
 + #include "magic.h"
 + #include "der.h"
 + #else
 ++#ifndef PHP_WIN32
 + #include <sys/mman.h>
 ++#endif
 + #include <sys/stat.h>
 + #include <err.h>
 + #endif
 +@@ -201,6 +203,7 @@
 + der_data(char *buf, size_t blen, uint32_t tag, const void *q, uint32_t len)
 + {
 +      const uint8_t *d = CAST(const uint8_t *, q);
 ++     uint32_t i;
 +      switch (tag) {
 +      case DER_TAG_PRINTABLE_STRING:
 +      case DER_TAG_UTF8_STRING:
 +@@ -211,7 +214,7 @@
 +              break;
 +      }
 +              
 +-     for (uint32_t i = 0; i < len; i++) {
 ++     for (i = 0; i < len; i++) {
 +              uint32_t z = i << 1;
 +              if (z < blen - 2)
 +                      snprintf(buf + z, blen - z, "%.2x", d[i]);
  diff -u libmagic.orig/elfclass.h libmagic/elfclass.h
- --- libmagic.orig/elfclass.h  2016-11-23 17:08:25.910282200 +0100
- +++ libmagic/elfclass.h       2015-07-18 21:35:36.472082600 +0200
 ---- libmagic.orig/elfclass.h  2017-04-10 11:41:09.731268025 +0800
 -+++ libmagic/elfclass.h       2017-04-10 11:41:14.412268021 +0800
++--- libmagic.orig/elfclass.h  2017-04-10 11:46:03.857163505 +0800
+++++ libmagic/elfclass.h       2017-04-10 11:46:07.198493002 +0800
  @@ -41,7 +41,7 @@
                        return toomany(ms, "program headers", phnum);
                flags |= FLAGS_IS_CORE;
                    fsize, elf_getu16(swap, elfhdr.e_machine),
                    (int)elf_getu16(swap, elfhdr.e_shstrndx),
  diff -u libmagic.orig/file.h libmagic/file.h
- --- libmagic.orig/file.h      2016-11-26 14:20:33.428933800 +0100
- +++ libmagic/file.h   2016-11-26 14:20:33.993908600 +0100
 ---- libmagic.orig/file.h      2017-04-10 11:41:09.731268025 +0800
 -+++ libmagic/file.h   2017-04-10 11:41:14.412268021 +0800
++--- libmagic.orig/file.h      2017-04-10 11:46:03.857163505 +0800
+++++ libmagic/file.h   2017-04-10 11:46:07.198493002 +0800
  @@ -33,11 +33,9 @@
   #ifndef __file_h__
   #define __file_h__
   #define __RCSID(a)
   #endif
  diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
- --- libmagic.orig/fsmagic.c   2016-11-23 17:08:26.758003500 +0100
- +++ libmagic/fsmagic.c        2016-11-24 13:41:34.212917300 +0100
 ---- libmagic.orig/fsmagic.c   2017-04-10 11:41:09.730268025 +0800
 -+++ libmagic/fsmagic.c        2017-04-10 11:41:14.413268021 +0800
++--- libmagic.orig/fsmagic.c   2017-04-10 11:46:03.856163005 +0800
+++++ libmagic/fsmagic.c        2017-04-10 11:46:07.199493002 +0800
  @@ -63,27 +63,21 @@
   # define minor(dev)  ((dev) & 0xff)
   #endif
   #ifdef       S_IFSOCK
   #ifndef __COHERENT__
        case S_IFSOCK:
 -@@ -381,15 +238,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.)
 --              */
 --             if ((ms->flags & MAGIC_DEVICES) == 0 && sb->st_size == 0) {
 --                     if (mime) {
 --                             if (handle_mime(ms, mime, "x-empty") == -1)
 --                                     return -1;
 --                     } else if (file_printf(ms, "%sempty", COMMA) == -1)
 -+      */
 -+     if ((ms->flags & MAGIC_DEVICES) == 0 && sb->st_size == 0) {
 -+             if (mime) {
 -+                     if (handle_mime(ms, mime, "x-empty") == -1)
 -                              return -1;
 -+                     } else if (file_printf(ms, "%sempty", COMMA) == -1)
 -+                     return -1;
 -                      break;
 --             }
 -+     }
 -              ret = 0;
 -              break;
 - 
 -@@ -399,9 +256,5 @@
 -              /*NOTREACHED*/
 -      }
 - 
 --     if (!mime && did && ret == 0) {
 --         if (file_printf(ms, " ") == -1)
 --                 return -1;
 --     }
 -      return ret;
 - }
  diff -u libmagic.orig/funcs.c libmagic/funcs.c
- --- libmagic.orig/funcs.c     2016-11-23 17:08:26.917536700 +0100
- +++ libmagic/funcs.c  2016-11-24 13:42:04.163244800 +0100
 ---- libmagic.orig/funcs.c     2017-04-10 11:41:09.732268025 +0800
 -+++ libmagic/funcs.c  2017-04-10 11:41:14.413268021 +0800
++--- libmagic.orig/funcs.c     2017-04-10 11:46:03.864167005 +0800
+++++ libmagic/funcs.c  2017-04-10 11:46:07.199493002 +0800
  @@ -31,7 +31,6 @@
   #endif       /* lint */
   
        return rbuf;
   }
   
 -@@ -550,10 +523,11 @@
 -              if (ptr >= eptr - 3)
 -                      break;
 -              *ptr++ = '\\';
 --             *ptr++ = ((CAST(unsigned int, *s) >> 6) & 7) + '0';
 --             *ptr++ = ((CAST(unsigned int, *s) >> 3) & 7) + '0';
 --             *ptr++ = ((CAST(unsigned int, *s) >> 0) & 7) + '0';
 -+             *ptr++ = ((*s >> 6) & 7) + '0';
 -+             *ptr++ = ((*s >> 3) & 7) + '0';
 -+             *ptr++ = ((*s >> 0) & 7) + '0';
 -      }
 -      *ptr = '\0';
 -      return buf;
 - }
 -+
+ Common subdirectories: libmagic.orig/.libs and libmagic/.libs
  diff -u libmagic.orig/magic.c libmagic/magic.c
- --- libmagic.orig/magic.c     2016-11-23 17:08:27.605158000 +0100
- +++ libmagic/magic.c  2016-11-24 13:42:10.074024300 +0100
 ---- libmagic.orig/magic.c     2017-04-10 11:41:09.737268025 +0800
 -+++ libmagic/magic.c  2017-04-10 11:41:14.413268021 +0800
++--- libmagic.orig/magic.c     2017-04-10 11:46:03.872171005 +0800
+++++ libmagic/magic.c  2017-04-10 11:46:07.199493002 +0800
  @@ -25,11 +25,6 @@
    * SUCH DAMAGE.
    */
   public const char *
   magic_error(struct magic_set *ms)
  diff -u libmagic.orig/magic.h libmagic/magic.h
- --- libmagic.orig/magic.h     2016-11-23 17:08:27.691621600 +0100
- +++ libmagic/magic.h  2016-11-24 13:41:34.229416200 +0100
 ---- libmagic.orig/magic.h     2017-04-10 11:41:09.731268025 +0800
 -+++ libmagic/magic.h  2017-04-10 11:41:14.413268021 +0800
 -@@ -88,6 +88,7 @@
++--- libmagic.orig/magic.h     2017-04-10 11:46:03.857163505 +0800
+++++ libmagic/magic.h  2017-04-10 11:46:07.199493002 +0800
 +@@ -93,6 +93,7 @@
   
   const char *magic_getpath(const char *, int);
   const char *magic_file(magic_t, const char *);
   int magic_list(magic_t, const char *);
   int magic_errno(magic_t);
   
 -diff -u libmagic.orig/patchlevel.h libmagic/patchlevel.h
 ---- libmagic.orig/patchlevel.h        2017-04-10 11:41:09.731268025 +0800
 -+++ libmagic/patchlevel.h     2017-04-10 11:41:14.414268021 +0800
 -@@ -1,34 +1,43 @@
 - #define      FILE_VERSION_MAJOR      5
 --#define      patchlevel              6
 -+#define      patchlevel              22
 - 
 - /*
 -  * Patchlevel file for Ian Darwin's MAGIC command.
 -- * $File: patchlevel.h,v 1.76 2011/01/17 16:40:41 christos Exp $
 -+ * $File: patchlevel.h,v 1.68 2008/03/22 21:39:43 christos Exp $
 -  *
 -- * $Log: patchlevel.h,v $
 -- * Revision 1.77  2011/04/15 22:07:27  christos
 -- * fix the patchlevel.
 -+ * $Log$
 -+ * Revision 1.9  2015/03/06 22:27:12 ab
 -+ * Update libmagic to 5.2X
 -  *
 -- * Revision 1.76  2011/01/17 16:40:41  christos
 -- * welcome to 5_05
 -+ * $Log$
 -+ * Revision 1.8  2014/02/18 22:27:12 ab
 -+ * Update libmagic to 5.17
 -  *
 -- * Revision 1.75  2010/01/22 21:08:13  christos
 -- * welcome to 5.04
 -+ * $Log$
 -+ * Revision 1.7  2013/03/26 22:27:12 ab
 -+ * Update libmagic to 5.14
 -  *
 -- * Revision 1.74  2009/05/06 20:32:48  christos
 -- * welcome to 5.03
 -+ * $Log$
 -+ * Revision 1.6  2012/03/26 21:01:37 ab
 -+ * Update libmagic to 5.11
 -  *
 -- * Revision 1.73  2009/05/04 15:15:13  christos
 -- * 5.02...
 -+ * Revision 1.5  2012/03/25 13:54:37  ab
 -+ * Update libmagic to 5.04
 -  *
 -- * Revision 1.72  2009/04/30 21:20:15  christos
 -- * 5.01 we are almost here.
 -+ * Revision 1.4  2009/05/04 20:52:43  scottmac
 -+ * Update libmagic to 5.02
 -  *
 -- * Revision 1.71  2009/01/21 19:09:42  christos
 -- * file 5.0
 -+ * Revision 1.3  2009/03/15 23:02:35  scottmac
 -+ * Update fileinfo to libmagic 5.00 and remove dependency on dirent.h on Windows
 -  *
 -- * Revision 1.70  2008/08/30 10:01:01  christos
 -- * file 4.26
 -+ * Revision 1.2  2008/11/02 16:09:27  scottmac
 -+ * Update libmagic to 4.26 and add support for v6 of the magic file format.
 -+ *
 -+ * Revision 1.1  2008/07/11 14:13:50  derick
 -+ * - Move lib to libmagic
 -+ *
 -+ * Revision 1.1  2008/07/11 14:10:50  derick
 -+ * - Step one for bundling the libmagic library. Some config.m4 issues left.
 -  *
 -  * Revision 1.69  2008/07/02 15:27:05  christos
 -  * welcome to 4.25
  diff -u libmagic.orig/print.c libmagic/print.c
- --- libmagic.orig/print.c     2016-11-23 17:08:28.349281600 +0100
- +++ libmagic/print.c  2016-11-24 13:42:04.178244800 +0100
 ---- libmagic.orig/print.c     2017-04-10 11:41:09.738268025 +0800
 -+++ libmagic/print.c  2017-04-10 11:41:14.414268021 +0800
 -@@ -28,13 +28,17 @@
++--- libmagic.orig/print.c     2017-04-10 11:46:03.872171005 +0800
+++++ libmagic/print.c  2017-04-10 11:46:07.199493002 +0800
 +@@ -28,6 +28,8 @@
   /*
    * print.c - debugging printout routines
    */
        if (tm == NULL)
                goto out;
  diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
- --- libmagic.orig/readcdf.c   2016-11-23 17:08:28.502932500 +0100
- +++ libmagic/readcdf.c        2016-11-24 13:42:04.185245900 +0100
 ---- libmagic.orig/readcdf.c   2017-04-10 11:41:09.737268025 +0800
 -+++ libmagic/readcdf.c        2017-04-10 11:41:14.414268021 +0800
 -@@ -26,15 +26,21 @@
 - #include "file.h"
 - 
 - #ifndef lint
 --FILE_RCSID("@(#)$File: readcdf.c,v 1.51 2015/01/11 16:58:25 christos Exp $")
 -+FILE_RCSID("@(#)$File: readcdf.c,v 1.50 2015/01/02 21:29:39 christos Exp $")
 - #endif
++--- libmagic.orig/readcdf.c   2017-04-10 11:46:03.871170505 +0800
+++++ libmagic/readcdf.c        2017-04-10 11:46:07.199493002 +0800
 +@@ -1,5 +1,5 @@
 + /*-
 +- * Copyright (c) 2008, 2016 Christos Zoulas
 ++ * Copyright (c) 2008 Christos Zoulas
 +  * All rights reserved.
 +  *
 +  * Redistribution and use in source and binary forms, with or without
 +@@ -31,7 +31,11 @@
   
 --#include <assert.h>
 + #include <assert.h>
   #include <stdlib.h>
  +#ifdef PHP_WIN32
  +#include "win32/unistd.h"
                                           if (c != NULL &&
                                            (ec = strchr(c, '\n')) != NULL)
                                                *ec = '\0';
 -@@ -362,7 +361,7 @@
 -      int i;
 - 
 -      if ((i = cdf_read_user_stream(info, h, sat, ssat, sst,
 --         dir, "Catalog", scn)) == -1)
 -+         dir, "Catalog", scn)) <= 0)
 -              return i;
 - #ifdef CDF_DEBUG
 -      cdf_dump_catalog(&h, &scn);
  diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
- --- libmagic.orig/softmagic.c 2016-11-23 17:08:28.915798800 +0100
- +++ libmagic/softmagic.c      2016-11-24 13:42:10.086018300 +0100
 ---- libmagic.orig/softmagic.c 2017-04-10 11:41:09.730268025 +0800
 -+++ libmagic/softmagic.c      2017-04-10 11:41:14.414268021 +0800
 -@@ -36,11 +36,19 @@
 - #endif       /* lint */
 - 
 - #include "magic.h"
 --#include <assert.h>
 - #include <string.h>
 - #include <ctype.h>
 - #include <stdlib.h>
++--- libmagic.orig/softmagic.c 2017-04-10 11:46:03.856163005 +0800
+++++ libmagic/softmagic.c      2017-04-10 11:46:07.200493002 +0800
 +@@ -43,6 +43,10 @@
   #include <time.h>
 -+#if defined(HAVE_LOCALE_H)
 -+#include <locale.h>
 -+#endif
 -+
 + #include "der.h"
 + 
  +#ifndef PREG_OFFSET_CAPTURE
  +# define PREG_OFFSET_CAPTURE                 (1<<8)
  +#endif
        }
        case FILE_INDIRECT:
  diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c
- --- libmagic.orig/strcasestr.c        2016-11-23 17:08:29.069351700 +0100
- +++ libmagic/strcasestr.c     2015-07-18 21:35:36.510103100 +0200
 ---- libmagic.orig/strcasestr.c        2017-04-10 11:41:09.737268025 +0800
 -+++ libmagic/strcasestr.c     2017-04-10 11:41:14.415268021 +0800
++--- libmagic.orig/strcasestr.c        2017-04-10 11:46:03.872171005 +0800
+++++ libmagic/strcasestr.c     2017-04-10 11:46:07.200493002 +0800
  @@ -39,6 +39,8 @@
   
   #include "file.h"
Simple merge