Skip to content

Commit c301467

Browse files
committed
Fixed bug #67731 finfo::file() returns invalid mime type for binary files
1 parent 13b45a3 commit c301467

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

ext/fileinfo/libmagic/funcs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "file.h"
2828

2929
#ifndef lint
30-
FILE_RCSID("@(#)$File: funcs.c,v 1.67 2014/02/12 23:20:53 christos Exp $")
30+
FILE_RCSID("@(#)$File: funcs.c,v 1.68 2014/02/18 11:09:31 kim Exp $")
3131
#endif /* lint */
3232

3333
#include "magic.h"
@@ -173,8 +173,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
173173
const char *code_mime = "binary";
174174
const char *type = "application/octet-stream";
175175
const char *def = "data";
176-
177-
176+
const char *ftype = NULL;
178177

179178
if (nb == 0) {
180179
def = "empty";
@@ -187,7 +186,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
187186

188187
if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
189188
looks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen,
190-
&code, &code_mime, &type);
189+
&code, &code_mime, &ftype);
191190
}
192191

193192
#ifdef __EMX__
@@ -272,7 +271,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
272271
if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
273272
if (looks_text == 0)
274273
if ((m = file_ascmagic_with_encoding( ms, ubuf,
275-
nb, u8buf, ulen, code, type, looks_text))
274+
nb, u8buf, ulen, code, ftype, looks_text))
276275
!= 0) {
277276
if ((ms->flags & MAGIC_DEBUG) != 0)
278277
(void)fprintf(stderr,

ext/fileinfo/tests/finfo_buffer_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ string(15) "MIFF image data"
4848
string(25) "RIFF (little-endian) data"
4949
string(28) "text/plain; charset=us-ascii"
5050
string(26) "text/plain; charset=ebcdic"
51-
string(22) "binary; charset=binary"
51+
string(40) "application/octet-stream; charset=binary"
5252
string(28) "text/plain; charset=us-ascii"
5353
string(28) "text/plain; charset=us-ascii"
5454
string(25) "text/plain; charset=utf-8"

ext/fileinfo/tests/finfo_buffer_variation1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ string(15) "MIFF image data"
4747
string(25) "RIFF (little-endian) data"
4848
string(28) "text/plain; charset=us-ascii"
4949
string(26) "text/plain; charset=ebcdic"
50-
string(22) "binary; charset=binary"
50+
string(40) "application/octet-stream; charset=binary"
5151
string(28) "text/plain; charset=us-ascii"
5252
string(28) "text/plain; charset=us-ascii"
5353
string(25) "text/plain; charset=utf-8"

0 commit comments

Comments
 (0)