Re: cvs: php4 /ext/mime_magic mime_magic.c

From: Date: Fri, 15 Nov 2002 16:07:46 +0000
Subject: Re: cvs: php4 /ext/mime_magic mime_magic.c
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-16271@lists.php.net to get a copy of this message
On November 15, 2002 10:50 am, Moriyoshi Koizumi wrote: > MSVCRT's fgets() can handle both "\r\n" and "\n" under text mode, and > the > magic file is always a text file. Why not use text mode for it? According to MSDN 'fgets reads characters from the current stream position to and including the first newline character, to the end of the stream, or until the number of characters read is equal to n - 1, whichever comes first.' There is no mention of only \r\n or \n handling regardless of the mode of operation. The magic file that comes bundled with Windows distro, originates from a UNIX system, meaning that it'll always have \n line endings. The data stored in the file may contain binary characters, so the 'b' flag adds a level of safety in the event it does contain binary data in the future. Ilia > Anyway using "r" should be discouraged, because cli and cgi SAPI > forcefully set the default CR handling mode to binary with setmode() > function while apache SAPI doesn't. > > Moriyoshi > > "Ilia A." <ilia@prohost.org> wrote: > > Are you absolutely certain that it is safe to open the magic file as text > > and not binary on Windows? > > > > Ilia > > > > On November 15, 2002 10:13 am, Moriyoshi Koizumi wrote: > > > 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; > > > } > > > > -- > > PHP CVS Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.cvs (#16271) next »