cvs: php4 /ext/mime_magic mime_magic.c

From: Date: Fri, 15 Nov 2002 15:13:31 +0000
Subject: cvs: php4 /ext/mime_magic mime_magic.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-16251@lists.php.net to get a copy of this message
moriyoshi Fri Nov 15 10:13:31 2002 EDT Modified files: /php4/ext/mime_magic mime_magic.c Log: Fixed segfault in case the specified magic file cannot be read. Index: php4/ext/mime_magic/mime_magic.c diff -u php4/ext/mime_magic/mime_magic.c:1.14 php4/ext/mime_magic/mime_magic.c:1.15 --- php4/ext/mime_magic/mime_magic.c:1.14 Thu Nov 14 20:45:23 2002 +++ php4/ext/mime_magic/mime_magic.c Fri Nov 15 10:13:30 2002 @@ -15,7 +15,7 @@ | Author: Hartmut Holzgraefe <hartmut@six.de> | +----------------------------------------------------------------------+ - $Id: mime_magic.c,v 1.14 2002/11/15 01:45:23 moriyoshi Exp $ + $Id: mime_magic.c,v 1.15 2002/11/15 15:13:30 moriyoshi Exp $ This module contains a lot of stuff taken from Apache mod_mime_magic, so the license section is a little bit longer than usual: @@ -304,6 +304,11 @@ 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 @@ 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; }

« previous php.cvs (#16251) next »