From: Pierre Joye Date: Thu, 6 Nov 2008 13:56:49 +0000 (+0000) Subject: - MFH X-Git-Tag: BEFORE_HEAD_NS_CHANGE~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=510d80e388ec37a0d3dbf853b01db8600ee4fbdf;p=php - MFH - add 64bit typedef support - fix vc6 build (1/2) - still broken/does not build cleanly, more to come --- diff --git a/ext/fileinfo/config.w32 b/ext/fileinfo/config.w32 index f94929c81f..085f9b2c3e 100644 --- a/ext/fileinfo/config.w32 +++ b/ext/fileinfo/config.w32 @@ -13,6 +13,10 @@ if (PHP_FILEINFO != 'no') { magic.c print.c \ readelf.c softmagic.c"; + if (VCVERS <1500) { + ADD_FLAG('CFLAGS', '/Zm1000'); + } + EXTENSION('fileinfo', 'fileinfo.c', true, "/I" + configure_module_dirname + "/libmagic /I" + configure_module_dirname); ADD_SOURCES(configure_module_dirname + '\\libmagic', LIBMAGIC_SOURCES, "fileinfo"); } else { diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index 1db520c41a..8b012c1aef 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -324,7 +324,7 @@ PHP_FUNCTION(finfo_open) RETURN_FALSE; } - if (file && *file) { /* user specified filed, perform open_basedir checks */ + if (file && *file) { /* user specified file, perform open_basedir checks */ if (!VCWD_REALPATH(file, resolved_path)) { RETURN_FALSE; } @@ -533,9 +533,6 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime php_stream *stream = php_stream_open_wrapper_ex(buffer, "rb", REPORT_ERRORS, NULL, context); if (!stream) { - if (mimetype_emu) { - magic_close(magic); - } RETVAL_FALSE; goto clean; } @@ -545,6 +542,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime } break; } + default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can only process string or stream arguments"); } diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index 6879c2f078..6f4b723812 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -584,7 +584,7 @@ private void load_1(struct magic_set *ms, int action, const char *fn, int *errs, struct magic_entry **marray, uint32_t *marraycount) { - zstr buffer; + char buffer[BUFSIZ + 1]; char *line; size_t line_len; size_t lineno = 0; @@ -598,13 +598,14 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs, #else stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL); #endif + if (stream == NULL) { if (errno != ENOENT) file_error(ms, errno, "cannot read magic file `%s'", fn); (*errs)++; } else { - buffer.v = emalloc(BUFSIZ+1); + /* read and parse this file */ for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &line_len)) != NULL; ms->line++) { if (line_len == 0) /* null line, garbage, etc */ @@ -652,7 +653,7 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs, if (parse(ms, marray, marraycount, line, lineno, action) != 0) (*errs)++; } - efree(buffer.v); + php_stream_close(stream); } } diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index 0950905007..deb420ec33 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -582,16 +582,16 @@ cvt_64(union VALUETYPE *p, const struct magic *m) if (m->num_mask) \ switch (m->mask_op & FILE_OPS_MASK) { \ case FILE_OPADD: \ - p->fld += cast m->num_mask; \ + p->fld += cast (int64_t)m->num_mask; \ break; \ case FILE_OPMINUS: \ - p->fld -= cast m->num_mask; \ + p->fld -= cast (int64_t)m->num_mask; \ break; \ case FILE_OPMULTIPLY: \ - p->fld *= cast m->num_mask; \ + p->fld *= cast (int64_t)m->num_mask; \ break; \ case FILE_OPDIVIDE: \ - p->fld /= cast m->num_mask; \ + p->fld /= cast (int64_t)m->num_mask; \ break; \ } \ @@ -1865,7 +1865,7 @@ magiccheck(struct magic_set *ms, struct magic *m) case 'x': if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu == *any* = 1\n", - (unsigned long long)v); + (uint64_t)v); matched = 1; break; @@ -1873,7 +1873,7 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v != l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu != %llu = %d\n", - (unsigned long long)v, (unsigned long long)l, + (uint64_t)v, (uint64_t)l, matched); break; @@ -1881,7 +1881,7 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v == l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu == %llu = %d\n", - (unsigned long long)v, (unsigned long long)l, + (uint64_t)v, (uint64_t)l, matched); break; @@ -1890,14 +1890,14 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v > l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu > %llu = %d\n", - (unsigned long long)v, - (unsigned long long)l, matched); + (uint64_t)v, + (uint64_t)l, matched); } else { matched = (int64_t) v > (int64_t) l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%lld > %lld = %d\n", - (long long)v, (long long)l, matched); + (uint64_t)v, (uint64_t)l, matched); } break; @@ -1906,14 +1906,14 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = v < l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%llu < %llu = %d\n", - (unsigned long long)v, - (unsigned long long)l, matched); + (uint64_t)v, + (uint64_t)l, matched); } else { matched = (int64_t) v < (int64_t) l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "%lld < %lld = %d\n", - (long long)v, (long long)l, matched); + (int64_t)v, (int64_t)l, matched); } break; @@ -1921,16 +1921,16 @@ magiccheck(struct magic_set *ms, struct magic *m) matched = (v & l) == l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n", - (unsigned long long)v, (unsigned long long)l, - (unsigned long long)l, matched); + (uint64_t)v, (uint64_t)l, + (uint64_t)l, matched); break; case '^': matched = (v & l) != l; if ((ms->flags & MAGIC_DEBUG) != 0) (void) fprintf(stderr, "((%llx & %llx) != %llx) = %d\n", - (unsigned long long)v, (unsigned long long)l, - (unsigned long long)l, matched); + (uint64_t)v, (uint64_t)l, + (uint64_t)l, matched); break; default: