summaryrefslogtreecommitdiff
path: root/ext/fileinfo
diff options
context:
space:
mode:
authorHartmut Holzgraefe <hholzgra@php.net>2004-04-21 22:49:35 +0000
committerHartmut Holzgraefe <hholzgra@php.net>2004-04-21 22:49:35 +0000
commit375b5df63d3e57520ddb1d08fea2dbe8ec50d59f (patch)
tree493e0c37fdf5b8f8119101b2fbabea0fd1f77c8f /ext/fileinfo
parentc94f0276b0642c4fc55ff3c9e7c65b384ce17ae6 (diff)
downloadphp-git-375b5df63d3e57520ddb1d08fea2dbe8ec50d59f.tar.gz
libmagic will only consume up to HOWMANY (hardcoded to 65536) bytes
from a file, so lets save bandwith and memory by limiting us to this
Diffstat (limited to 'ext/fileinfo')
-rw-r--r--ext/fileinfo/fileinfo.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index e42985012e..8f7e0aa8f3 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -23,6 +23,12 @@
#endif
#include <magic.h>
+// HOWMANY specifies the maximum offset libmagic will look at
+// this is currently hardcoded in the libmagic source but not exported
+#ifndef HOWMANY
+#define HOWMANY 65536
+#endif
+
#include "php.h"
#include "php_ini.h"
@@ -361,7 +367,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode)
if (!stream) {
RETURN_FALSE;
}
- buffer_len = php_stream_copy_to_mem(stream, &tmp, PHP_STREAM_COPY_ALL, 0);
+ buffer_len = php_stream_copy_to_mem(stream, &tmp, HOWMANY, 0); //
php_stream_close(stream);
if (buffer_len == 0) {