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?

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." <[EMAIL PROTECTED]> 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  <[EMAIL PROTECTED]>                         |
> >
> >    +----------------------------------------------------------------------+
> >
> > -  $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
> 


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to