www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/06/28/08:47:41

From: cgf AT cygnus DOT com (Christopher Faylor)
Subject: Re: What does it mean?
28 Jun 1998 08:47:41 -0700 :
Message-ID: <199806281544.LAA23472.cygnus.cygwin32.developers@kramden.cygnus.com>
To: cygwin32-developers AT cygnus DOT com, sos AT prospect DOT com DOT ru

>From: Sergey Okhapkin <sos AT prospect DOT com DOT ru>
>Date: Sun, 28 Jun 1998 14:00:58 +0400
>
>fhandler_disk_file::open() contains the following code:
>
>  if ((os_being_run != winNT) && (!real_path.exec_p))
>    {
>    DWORD done;
>    char magic[2];
>    /* FIXME should we use /etc/magic ? */
>    magic[0] = magic[1] = magic[2] = '\0';
>    ReadFile (get_handle (), magic, 3, &done, 0);
>    if (magic[0] == ':' && magic[1] == '\n')
>        real_path.exec_p = 1;
>
>    if (magic[0] == '#' && magic[1] == '!')
>        real_path.exec_p = 1;
>    if (flags & O_APPEND)
>      SetFilePointer (get_handle(), 0, 0, FILE_END);
>    else
>      SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
>    }
>
>The code seems to me buggy! Why we do not check file magic and do not set file pointer on NT? Shouldn't the code be something like:
>
>  if (!real_path.exec_p)
>    {
>    DWORD done;
>    char magic[2];
>    /* FIXME should we use /etc/magic ? */
>    magic[0] = magic[1] = magic[2] = '\0';
>    ReadFile (get_handle (), magic, 3, &done, 0);
>    if (magic[0] == ':' && magic[1] == '\n')
>        real_path.exec_p = 1;
>
>    if (magic[0] == '#' && magic[1] == '!')
>        real_path.exec_p = 1;
>    }
>  if (flags & O_APPEND)
>    SetFilePointer (get_handle(), 0, 0, FILE_END);
>  else
>    SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);

Looks like a bug to me.  I don't see what NT has to do with anything.
Wanna submit a patch?

cgf

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019