]> granicus.if.org Git - php/commitdiff
Fixed bug #67731 finfo::file() returns invalid mime type for binary files
authorAnatol Belski <ab@php.net>
Sat, 30 Aug 2014 02:04:42 +0000 (04:04 +0200)
committerAnatol Belski <ab@php.net>
Sat, 30 Aug 2014 02:04:42 +0000 (04:04 +0200)
ext/fileinfo/libmagic/funcs.c
ext/fileinfo/tests/finfo_buffer_basic.phpt
ext/fileinfo/tests/finfo_buffer_variation1.phpt

index e1aa7b9c3decf2a7810393d03a48b2889c70a8d1..bd6d3d592e911f140848f0767612dad25a15b18c 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.67 2014/02/12 23:20:53 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.68 2014/02/18 11:09:31 kim Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -173,8 +173,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
        const char *code_mime = "binary";
        const char *type = "application/octet-stream";
        const char *def = "data";
-
-
+       const char *ftype = NULL;
 
        if (nb == 0) {
                def = "empty";
@@ -187,7 +186,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
 
        if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
                looks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen,
-                   &code, &code_mime, &type);
+                   &code, &code_mime, &ftype);
        }
 
 #ifdef __EMX__
@@ -272,7 +271,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
                if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
                        if (looks_text == 0)
                                if ((m = file_ascmagic_with_encoding( ms, ubuf,
-                                   nb, u8buf, ulen, code, type, looks_text))
+                                   nb, u8buf, ulen, code, ftype, looks_text))
                                    != 0) {
                                        if ((ms->flags & MAGIC_DEBUG) != 0)
                                                (void)fprintf(stderr,
index d8dcfab7a0ccd45bfd07799e0ef3166008a40da9..0c3c641388f3952a0ce21b8eb8ecc8b28a3f56ff 100644 (file)
@@ -48,7 +48,7 @@ string(15) "MIFF image data"
 string(25) "RIFF (little-endian) data"
 string(28) "text/plain; charset=us-ascii"
 string(26) "text/plain; charset=ebcdic"
-string(22) "binary; charset=binary"
+string(40) "application/octet-stream; charset=binary"
 string(28) "text/plain; charset=us-ascii"
 string(28) "text/plain; charset=us-ascii"
 string(25) "text/plain; charset=utf-8"
index d9c9be03e3b26d84b391753507583a78d70e92e8..4fdd2be272fc52715864553210b2ebb4f5cf92b3 100644 (file)
@@ -47,7 +47,7 @@ string(15) "MIFF image data"
 string(25) "RIFF (little-endian) data"
 string(28) "text/plain; charset=us-ascii"
 string(26) "text/plain; charset=ebcdic"
-string(22) "binary; charset=binary"
+string(40) "application/octet-stream; charset=binary"
 string(28) "text/plain; charset=us-ascii"
 string(28) "text/plain; charset=us-ascii"
 string(25) "text/plain; charset=utf-8"