diff options
author | Moriyoshi Koizumi <moriyoshi@php.net> | 2002-11-15 15:13:30 +0000 |
---|---|---|
committer | Moriyoshi Koizumi <moriyoshi@php.net> | 2002-11-15 15:13:30 +0000 |
commit | 3ecc71a0992986211abea36154c812b5fb3e6ae6 (patch) | |
tree | 13c1656a63e01ce6977d81198b35dd7aa47fc5f5 /ext/mime_magic | |
parent | 1391f774cfb69e9002a95f2edf057b44f087b219 (diff) | |
download | php-git-3ecc71a0992986211abea36154c812b5fb3e6ae6.tar.gz |
Fixed segfault in case the specified magic file cannot be read.
Diffstat (limited to 'ext/mime_magic')
-rw-r--r-- | ext/mime_magic/mime_magic.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c index 474182d181..6e5b308fb9 100644 --- a/ext/mime_magic/mime_magic.c +++ b/ext/mime_magic/mime_magic.c @@ -304,6 +304,11 @@ PHP_FUNCTION(mime_content_type) return; } + if ((int) conf->magic == -1) { + php_error(E_ERROR, MODNAME " could not be initialized, magic file %s is not avaliable", conf->magicfile); + RETURN_FALSE; + } + if(!conf->magic) { php_error(E_WARNING, MODNAME " not initialized"); RETURN_FALSE; @@ -343,10 +348,9 @@ static int apprentice(void) magic_server_config_rec *conf = &mime_global; fname = conf->magicfile; /* todo cwd? */ - f = fopen(fname, "r"); + f = fopen(fname, "rt"); if (f == NULL) { - php_error(E_WARNING, - MODNAME ": can't read magic file %s", fname); + (int) conf->magic = -1; return -1; } |