Commit:    57db68e03d46da1b1a2244e001550739c8eec468
Author:    Anatol Belski <a...@php.net>         Thu, 28 Nov 2013 23:44:24 +0100
Parents:   ef54a95b7184899c63b4bd7be400c4621dd36360
Branches:  str_size_and_int64

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=57db68e03d46da1b1a2244e001550739c8eec468

Log:
fixed ext/fileinfo

XXX update libmagic.patch

Changed paths:
  M  ext/fileinfo/fileinfo.c
  M  ext/fileinfo/libmagic/apprentice.c
  M  ext/fileinfo/libmagic/cdf.c
  M  ext/fileinfo/libmagic/compress.c
  M  ext/fileinfo/libmagic/elfclass.h
  M  ext/fileinfo/libmagic/file.h
  M  ext/fileinfo/libmagic/fsmagic.c
  M  ext/fileinfo/libmagic/funcs.c
  M  ext/fileinfo/libmagic/readcdf.c
  M  ext/fileinfo/libmagic/readelf.c
  M  ext/fileinfo/libmagic/softmagic.c

diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index 799891e..9d6bf6a 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -44,7 +44,7 @@
 
 /* {{{ macros and type definitions */
 struct php_fileinfo {
-       long options;
+       php_int_t options;
        struct magic_set *magic;
 };
 
@@ -177,7 +177,7 @@ zend_function_entry finfo_class_functions[] = {
 /* }}} */
 
 #define FINFO_SET_OPTION(magic, options) \
-       if (magic_setflags(magic, options) == -1) { \
+       if (magic_setflags(magic, (int)options) == -1) { \
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to set 
option '%ld' %d:%s", \
                                options, magic_errno(magic), 
magic_error(magic)); \
                RETURN_FALSE; \
@@ -289,14 +289,14 @@ PHP_MINFO_FUNCTION(fileinfo)
    Create a new fileinfo resource. */
 PHP_FUNCTION(finfo_open)
 {
-       long options = MAGIC_NONE;
+       php_int_t options = MAGIC_NONE;
        char *file = NULL;
-       int file_len = 0;
+       zend_str_size_int file_len = 0;
        struct php_fileinfo *finfo;
        FILEINFO_DECLARE_INIT_OBJECT(object)
        char resolved_path[MAXPATHLEN];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lp", &options, 
&file, &file_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iP", &options, 
&file, &file_len) == FAILURE) {
                FILEINFO_DESTROY_OBJECT(object);
                RETURN_FALSE;
        }
@@ -380,18 +380,18 @@ PHP_FUNCTION(finfo_close)
    Set libmagic configuration options. */
 PHP_FUNCTION(finfo_set_flags)
 {
-       long options;
+       php_int_t options;
        struct php_fileinfo *finfo;
        zval *zfinfo;
        FILEINFO_DECLARE_INIT_OBJECT(object)
 
        if (object) {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", 
&options) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", 
&options) == FAILURE) {
                        RETURN_FALSE;
                }
                FILEINFO_FROM_OBJECT(finfo, object);
        } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", 
&zfinfo, &options) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", 
&zfinfo, &options) == FAILURE) {
                        RETURN_FALSE;
                }
                ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, 
"file_info", le_fileinfo);
@@ -410,9 +410,9 @@ PHP_FUNCTION(finfo_set_flags)
 
 static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int 
mimetype_emu) /* {{{ */
 {
-       long options = 0;
+       php_int_t options = 0;
        char *ret_val = NULL, *buffer = NULL;
-       int buffer_len;
+       zend_str_size_int buffer_len;
        struct php_fileinfo *finfo = NULL;
        zval *zfinfo, *zcontext = NULL;
        zval *what;
@@ -431,7 +431,7 @@ static void 
_php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
                switch (Z_TYPE_P(what)) {
                        case IS_STRING:
                                buffer = Z_STRVAL_P(what);
-                               buffer_len = Z_STRLEN_P(what);
+                               buffer_len = Z_STRSIZE_P(what);
                                mode = FILEINFO_MODE_FILE;
                                break;
 
@@ -450,13 +450,13 @@ static void 
_php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
                        goto common;
                }
        } else if (object) {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lr", 
&buffer, &buffer_len, &options, &zcontext) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ir", 
&buffer, &buffer_len, &options, &zcontext) == FAILURE) {
                        RETURN_FALSE;
                }
                FILEINFO_FROM_OBJECT(finfo, object);
                magic = finfo->magic;
        } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|lr", 
&zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS|ir", 
&zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
                        RETURN_FALSE;
                }
                ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, 
"file_info", le_fileinfo);
@@ -478,7 +478,7 @@ static void 
_php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
                case FILEINFO_MODE_STREAM:
                {
                                php_stream *stream;
-                               off_t streampos;
+                               zend_off_t streampos;
 
                                php_stream_from_zval_no_verify(stream, &what);
                                if (!stream) {
diff --git a/ext/fileinfo/libmagic/apprentice.c 
b/ext/fileinfo/libmagic/apprentice.c
index 11920e6..8fde5b4 100644
--- a/ext/fileinfo/libmagic/apprentice.c
+++ b/ext/fileinfo/libmagic/apprentice.c
@@ -1134,7 +1134,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int 
action)
        uint32_t i, j;
        size_t files = 0, maxfiles = 0;
        char **filearr = NULL;
-       struct stat st;
+       zend_stat_t st;
        struct magic_map *map;
        php_stream *dir;
        php_stream_dirent d;
@@ -1182,7 +1182,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int 
action)
                                php_stream_closedir(dir);
                                goto out;
                        }
-                       if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
+                       if (zend_stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
                                continue;
                        }
                        if (files >= maxfiles) {
@@ -2691,7 +2691,7 @@ internal_loaded:
        if (NULL != fn) {
                nentries = (uint32_t)(st.sb.st_size / sizeof(struct magic));
                entries = (uint32_t)(st.sb.st_size / sizeof(struct magic));
-               if ((off_t)(entries * sizeof(struct magic)) != st.sb.st_size) {
+               if ((zend_off_t)(entries * sizeof(struct magic)) != 
st.sb.st_size) {
                        file_error(ms, 0, "Size of `%s' %llu is not a multiple 
of %zu",
                                dbname, (unsigned long long)st.sb.st_size,
                                sizeof(struct magic));
@@ -2785,7 +2785,7 @@ apprentice_compile(struct magic_set *ms, struct magic_map 
*map, const char *fn)
 
        assert(nm + sizeof(ar) < m);
 
-       if (php_stream_seek(stream,(off_t)sizeof(struct magic), SEEK_SET) != 
sizeof(struct magic)) {
+       if (php_stream_seek(stream,(zend_off_t)sizeof(struct magic), SEEK_SET) 
!= sizeof(struct magic)) {
                file_error(ms, errno, "error seeking `%s'", dbname);
                goto out;
        }
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
index dd7177e..7954c04 100644
--- a/ext/fileinfo/libmagic/cdf.c
+++ b/ext/fileinfo/libmagic/cdf.c
@@ -289,11 +289,11 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const 
cdf_header_t *h,
 }
 
 static ssize_t
-cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
+cdf_read(const cdf_info_t *info, zend_off_t off, void *buf, size_t len)
 {
        size_t siz = (size_t)off + len;
 
-       if ((off_t)(off + len) != (off_t)siz) {
+       if ((zend_off_t)(off + len) != (zend_off_t)siz) {
                errno = EINVAL;
                return -1;
        }
@@ -306,7 +306,7 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, 
size_t len)
        if (info->i_fd == -1)
                return -1;
 
-       if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (off_t)-1)
+       if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (zend_off_t)-1)
                return -1;
 
        if (FINFO_READ_FUNC(info->i_fd, buf, len) != (ssize_t)len)
@@ -321,7 +321,7 @@ cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
        char buf[512];
 
        (void)memcpy(cdf_bo.s, "\01\02\03\04", 4);
-       if (cdf_read(info, (off_t)0, buf, sizeof(buf)) == -1)
+       if (cdf_read(info, (zend_off_t)0, buf, sizeof(buf)) == -1)
                return -1;
        cdf_unpack_header(h, buf);
        cdf_swap_header(h);
@@ -355,7 +355,7 @@ cdf_read_sector(const cdf_info_t *info, void *buf, size_t 
offs, size_t len,
        size_t ss = CDF_SEC_SIZE(h);
        size_t pos = CDF_SEC_POS(h, id);
        assert(ss == len);
-       return cdf_read(info, (off_t)pos, ((char *)buf) + offs, len);
+       return cdf_read(info, (zend_off_t)pos, ((char *)buf) + offs, len);
 }
 
 ssize_t
diff --git a/ext/fileinfo/libmagic/compress.c b/ext/fileinfo/libmagic/compress.c
index 9f26dd0..93b99ed 100644
--- a/ext/fileinfo/libmagic/compress.c
+++ b/ext/fileinfo/libmagic/compress.c
@@ -301,7 +301,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void 
*startbuf,
                return -1;
        }
        (void)close(tfd);
-       if (FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
+       if (FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) {
                file_badseek(ms);
                return -1;
        }
@@ -407,7 +407,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
                (void) close(0);
                if (fd != -1) {
                    (void) dup(fd);
-                   (void) FINFO_LSEEK_FUNC(0, (off_t)0, SEEK_SET);
+                   (void) FINFO_LSEEK_FUNC(0, (zend_off_t)0, SEEK_SET);
                } else {
                    (void) dup(fdin[0]);
                    (void) close(fdin[0]);
diff --git a/ext/fileinfo/libmagic/elfclass.h b/ext/fileinfo/libmagic/elfclass.h
index 010958a..bfacceb 100644
--- a/ext/fileinfo/libmagic/elfclass.h
+++ b/ext/fileinfo/libmagic/elfclass.h
@@ -37,7 +37,7 @@
        case ET_CORE:
                flags |= FLAGS_IS_CORE;
                if (dophn_core(ms, clazz, swap, fd,
-                   (off_t)elf_getu(swap, elfhdr.e_phoff),
+                   (zend_off_t)elf_getu(swap, elfhdr.e_phoff),
                    elf_getu16(swap, elfhdr.e_phnum), 
                    (size_t)elf_getu16(swap, elfhdr.e_phentsize),
                    fsize, &flags) == -1)
@@ -47,7 +47,7 @@
        case ET_EXEC:
        case ET_DYN:
                if (dophn_exec(ms, clazz, swap, fd,
-                   (off_t)elf_getu(swap, elfhdr.e_phoff),
+                   (zend_off_t)elf_getu(swap, elfhdr.e_phoff),
                    elf_getu16(swap, elfhdr.e_phnum), 
                    (size_t)elf_getu16(swap, elfhdr.e_phentsize),
                    fsize, &flags, elf_getu16(swap, elfhdr.e_shnum))
@@ -56,7 +56,7 @@
                /*FALLTHROUGH*/
        case ET_REL:
                if (doshn(ms, clazz, swap, fd,
-                   (off_t)elf_getu(swap, elfhdr.e_shoff),
+                   (zend_off_t)elf_getu(swap, elfhdr.e_shoff),
                    elf_getu16(swap, elfhdr.e_shnum),
                    (size_t)elf_getu16(swap, elfhdr.e_shentsize),
                    fsize, &flags, elf_getu16(swap, elfhdr.e_machine),
diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h
index 19b6872..8e62361 100644
--- a/ext/fileinfo/libmagic/file.h
+++ b/ext/fileinfo/libmagic/file.h
@@ -395,7 +395,7 @@ struct magic_set {
        struct {
                const char *s;          /* start of search in original source */
                size_t s_len;           /* length of search region */
-               size_t offset;          /* starting offset in source: XXX - 
should this be off_t? */
+               size_t offset;          /* starting offset in source: XXX - 
should this be zend_off_t? */
                size_t rm_len;          /* match length */
        } search;
 
diff --git a/ext/fileinfo/libmagic/fsmagic.c b/ext/fileinfo/libmagic/fsmagic.c
index d1381bd..8346379 100644
--- a/ext/fileinfo/libmagic/fsmagic.c
+++ b/ext/fileinfo/libmagic/fsmagic.c
@@ -90,7 +90,7 @@ handle_mime(struct magic_set *ms, int mime, const char *str)
 }
 
 protected int
-file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream 
*stream)
+file_fsmagic(struct magic_set *ms, const char *fn, zend_stat_t *sb, php_stream 
*stream)
 {
        int ret, did = 0;
        int mime = ms->flags & MAGIC_MIME;
diff --git a/ext/fileinfo/libmagic/funcs.c b/ext/fileinfo/libmagic/funcs.c
index 9c0d2bd..4dd7c3d 100644
--- a/ext/fileinfo/libmagic/funcs.c
+++ b/ext/fileinfo/libmagic/funcs.c
@@ -446,14 +446,15 @@ file_replace(struct magic_set *ms, const char *pat, const 
char *rep)
        pcre_cache_entry *pce;
        char *res;
        zval *repl;
-       int res_len, rep_cnt = 0;
+       zend_str_size_int res_len;
+       int rep_cnt = 0;
        TSRMLS_FETCH();
 
        MAKE_STD_ZVAL(patt);
        ZVAL_STRINGL(patt, pat, strlen(pat), 0);
        opts |= PCRE_MULTILINE;
        convert_libmagic_pattern(patt, opts);
-       if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(patt), 
Z_STRLEN_P(patt) TSRMLS_CC)) == NULL) {
+       if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(patt), 
Z_STRSIZE_P(patt) TSRMLS_CC)) == NULL) {
                zval_dtor(patt);
                FREE_ZVAL(patt);
                return -1;
diff --git a/ext/fileinfo/libmagic/readcdf.c b/ext/fileinfo/libmagic/readcdf.c
index 3abcc2e..16db60c 100644
--- a/ext/fileinfo/libmagic/readcdf.c
+++ b/ext/fileinfo/libmagic/readcdf.c
@@ -142,10 +142,12 @@ cdf_file_property_info(struct magic_set *ms, const 
cdf_property_info_t *info,
                                                 return -1;
                                 } else {
                                         char *c, *ec;
+                                       const time_t tmt;
                                         if (cdf_timestamp_to_timespec(&ts, tp) 
== -1) {
                                                                                
        return -1;
                                                                                
}
-                                        c = cdf_ctime(&ts.tv_sec, tbuf);
+                                        c = cdf_ctime(&tmt, tbuf);
+                                        ts.tv_sec = (long)tmt;
                                         if ((ec = strchr(c, '\n')) != NULL)
                                                 *ec = '\0';
 
diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c
index 1c3845f..e36d246 100644
--- a/ext/fileinfo/libmagic/readelf.c
+++ b/ext/fileinfo/libmagic/readelf.c
@@ -42,13 +42,13 @@ FILE_RCSID("@(#)$File: readelf.c,v 1.97 2013/03/06 03:35:30 
christos Exp $")
 #include "magic.h"
 
 #ifdef ELFCORE
-private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
-    off_t, int *);
+private int dophn_core(struct magic_set *, int, int, int, zend_off_t, int, 
size_t,
+    zend_off_t, int *);
 #endif
-private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
-    off_t, int *, int);
-private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
-    off_t, int *, int);
+private int dophn_exec(struct magic_set *, int, int, int, zend_off_t, int, 
size_t,
+    zend_off_t, int *, int);
+private int doshn(struct magic_set *, int, int, int, zend_off_t, int, size_t,
+    zend_off_t, int *, int);
 private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
     int, size_t, int *);
 
@@ -144,7 +144,7 @@ getu64(int swap, uint64_t value)
 #define xsh_size       (size_t)(clazz == ELFCLASS32            \
                         ? elf_getu32(swap, sh32.sh_size)       \
                         : elf_getu64(swap, sh64.sh_size))
-#define xsh_offset     (off_t)(clazz == ELFCLASS32             \
+#define xsh_offset     (zend_off_t)(clazz == ELFCLASS32                \
                         ? elf_getu32(swap, sh32.sh_offset)     \
                         : elf_getu64(swap, sh64.sh_offset))
 #define xsh_type       (clazz == ELFCLASS32                    \
@@ -162,13 +162,13 @@ getu64(int swap, uint64_t value)
 #define xph_type       (clazz == ELFCLASS32                    \
                         ? elf_getu32(swap, ph32.p_type)        \
                         : elf_getu32(swap, ph64.p_type))
-#define xph_offset     (off_t)(clazz == ELFCLASS32             \
+#define xph_offset     (zend_off_t)(clazz == ELFCLASS32                \
                         ? elf_getu32(swap, ph32.p_offset)      \
                         : elf_getu64(swap, ph64.p_offset))
 #define xph_align      (size_t)((clazz == ELFCLASS32           \
-                        ? (off_t) (ph32.p_align ?              \
+                        ? (zend_off_t) (ph32.p_align ?                 \
                            elf_getu32(swap, ph32.p_align) : 4) \
-                        : (off_t) (ph64.p_align ?              \
+                        : (zend_off_t) (ph64.p_align ?         \
                            elf_getu64(swap, ph64.p_align) : 4)))
 #define xph_filesz     (size_t)((clazz == ELFCLASS32           \
                         ? elf_getu32(swap, ph32.p_filesz)      \
@@ -293,8 +293,8 @@ private const char os_style_names[][8] = {
 #define FLAGS_IS_CORE          0x10
 
 private int
-dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
-    int num, size_t size, off_t fsize, int *flags)
+dophn_core(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off,
+    int num, size_t size, zend_off_t fsize, int *flags)
 {
        Elf32_Phdr ph32;
        Elf64_Phdr ph64;
@@ -312,7 +312,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int 
fd, off_t off,
         * Loop through all the program headers.
         */
        for ( ; num; num--) {
-               if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+               if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
                        file_badseek(ms);
                        return -1;
                }
@@ -334,7 +334,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int 
fd, off_t off,
                 * This is a PT_NOTE section; loop through all the notes
                 * in the section.
                 */
-               if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
+               if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == 
(zend_off_t)-1) {
                        file_badseek(ms);
                        return -1;
                }
@@ -849,14 +849,14 @@ static const cap_desc_t cap_desc_386[] = {
 };
 
 private int
-doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
-    size_t size, off_t fsize, int *flags, int mach, int strtab)
+doshn(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off, int 
num,
+    size_t size, zend_off_t fsize, int *flags, int mach, int strtab)
 {
        Elf32_Shdr sh32;
        Elf64_Shdr sh64;
        int stripped = 1;
        void *nbuf;
-       off_t noff, coff, name_off;
+       zend_off_t noff, coff, name_off;
        uint64_t cap_hw1 = 0;   /* SunOS 5.x hardware capabilites */
        uint64_t cap_sf1 = 0;   /* SunOS 5.x software capabilites */
        char name[50];
@@ -868,7 +868,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, 
off_t off, int num,
        }
 
        for ( ; num; num--) {
-               if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+               if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
                        file_badseek(ms);
                        return -1;
                }
@@ -898,8 +898,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, 
off_t off, int num,
                switch (xsh_type) {
                case SHT_NOTE:
                        nbuf = emalloc((size_t)xsh_size);
-                       if ((noff = FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, 
SEEK_SET)) ==
-                           (off_t)-1) {
+                       if ((noff = FINFO_LSEEK_FUNC(fd, 
(zend_off_t)xsh_offset, SEEK_SET)) ==
+                           (zend_off_t)-1) {
                                file_badread(ms);
                                efree(nbuf);
                                return -1;
@@ -913,7 +913,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, 
off_t off, int num,
 
                        noff = 0;
                        for (;;) {
-                               if (noff >= (off_t)xsh_size)
+                               if (noff >= (zend_off_t)xsh_size)
                                        break;
                                noff = donote(ms, nbuf, (size_t)noff,
                                    (size_t)xsh_size, clazz, swap, 4,
@@ -924,8 +924,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, 
off_t off, int num,
                        efree(nbuf);
                        break;
                case SHT_SUNW_cap:
-                       if (FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET) ==
-                           (off_t)-1) {
+                       if (FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, 
SEEK_SET) ==
+                           (zend_off_t)-1) {
                                file_badseek(ms);
                                return -1;
                        }
@@ -935,7 +935,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, 
off_t off, int num,
                                Elf64_Cap cap64;
                                char cbuf[/*CONSTCOND*/
                                    MAX(sizeof cap32, sizeof cap64)];
-                               if ((coff += xcap_sizeof) > (off_t)xsh_size)
+                               if ((coff += xcap_sizeof) > 
(zend_off_t)xsh_size)
                                        break;
                                if (FINFO_READ_FUNC(fd, cbuf, 
(size_t)xcap_sizeof) !=
                                    (ssize_t)xcap_sizeof) {
@@ -1038,8 +1038,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, 
off_t off, int num,
  * otherwise it's statically linked.
  */
 private int
-dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
-    int num, size_t size, off_t fsize, int *flags, int sh_num)
+dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off,
+    int num, size_t size, zend_off_t fsize, int *flags, int sh_num)
 {
        Elf32_Phdr ph32;
        Elf64_Phdr ph64;
@@ -1056,7 +1056,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int 
fd, off_t off,
        }
 
        for ( ; num; num--) {
-               if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+               if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
                        file_badseek(ms);
                        return -1;
                }
@@ -1100,7 +1100,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int 
fd, off_t off,
                         * This is a PT_NOTE section; loop through all the notes
                         * in the section.
                         */
-                       if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == 
(off_t)-1) {
+                       if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == 
(zend_off_t)-1) {
                                file_badseek(ms);
                                return -1;
                        }
@@ -1143,7 +1143,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned 
char *buf,
        int clazz;
        int swap;
        struct stat st;
-       off_t fsize;
+       zend_off_t fsize;
        int flags = 0;
        Elf32_Ehdr elf32hdr;
        Elf64_Ehdr elf64hdr;
@@ -1166,7 +1166,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned 
char *buf,
        /*
         * If we cannot seek, it must be a pipe, socket or fifo.
         */
-       if((FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == 
ESPIPE))
+       if((FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) && 
(errno == ESPIPE))
                fd = file_pipe2file(ms, fd, buf, nbytes);
 
        if (fstat(fd, &st) == -1) {
diff --git a/ext/fileinfo/libmagic/softmagic.c 
b/ext/fileinfo/libmagic/softmagic.c
index 0671fa9..a337c1e 100644
--- a/ext/fileinfo/libmagic/softmagic.c
+++ b/ext/fileinfo/libmagic/softmagic.c
@@ -1820,11 +1820,11 @@ convert_libmagic_pattern(zval *pattern, int options)
                int i, j=0;
                char *t;
 
-               t = (char *) safe_emalloc(Z_STRLEN_P(pattern), 2, 5);
+               t = (char *) safe_emalloc(Z_STRSIZE_P(pattern), 2, 5);
                
                t[j++] = '~';
                
-               for (i=0; i<Z_STRLEN_P(pattern); i++, j++) {
+               for (i=0; i<Z_STRSIZE_P(pattern); i++, j++) {
                        switch (Z_STRVAL_P(pattern)[i]) {
                                case '~':
                                        t[j++] = '\\';
@@ -1846,7 +1846,7 @@ convert_libmagic_pattern(zval *pattern, int options)
                t[j]='\0';
        
                Z_STRVAL_P(pattern) = t;
-               Z_STRLEN_P(pattern) = j;
+               Z_STRSIZE_P(pattern) = j;
 
 }
 
@@ -2026,7 +2026,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
                convert_libmagic_pattern(pattern, options);
                
                l = v = 0;
-               if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), 
Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
+               if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), 
Z_STRSIZE_P(pattern) TSRMLS_CC)) == NULL) {
                        zval_dtor(pattern);
                        FREE_ZVAL(pattern);
                        return -1;
@@ -2100,7 +2100,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
                                                                
                                                                
MAKE_STD_ZVAL(pattern_match);
                                                                
Z_STRVAL_P(pattern_match) = (char *)Z_STRVAL(matchcopy);
-                                                               
Z_STRLEN_P(pattern_match) = Z_STRLEN(matchcopy);
+                                                               
Z_STRSIZE_P(pattern_match) = Z_STRSIZE(matchcopy);
                                                                
Z_TYPE_P(pattern_match) = IS_STRING; 
 
                                                                
zval_dtor(&matchcopy);
@@ -2130,7 +2130,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
                                        if ((pattern_match != NULL) && 
(pattern_offset != NULL)) {
                                                ms->search.s += 
(int)Z_LVAL_P(pattern_offset); /* this is where the match starts */
                                                ms->search.offset += 
(size_t)Z_LVAL_P(pattern_offset); /* this is where the match starts as size_t */
-                                               ms->search.rm_len = 
Z_STRLEN_P(pattern_match) /* This is the length of the matched pattern */;
+                                               ms->search.rm_len = 
Z_STRSIZE_P(pattern_match) /* This is the length of the matched pattern */;
                                                v = 0;
                                                
                                                efree(pattern_match);
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to