delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/15/17:20:56

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Fri, 15 Dec 2000 17:17:33 -0500
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Possible Bug in file length calculation in normalize_posix_path
Message-ID: <20001215171733.A29106@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <3A3A93CD DOT FADEBCE AT airflash DOT com> <20001215170313 DOT A29060 AT redhat DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <20001215170313.A29060@redhat.com>; from cgf@redhat.com on Fri, Dec 15, 2000 at 05:03:13PM -0500

On Fri, Dec 15, 2000 at 05:03:13PM -0500, Christopher Faylor wrote:
>On Fri, Dec 15, 2000 at 01:57:33PM -0800, Alex Tang wrote:
>>Hello.
>>
>>I'm running the latest Cygwin 1.1.6 on a Windows NT (and Win2K)
>>machine.  (cygcheck information is located at the end of this
>>mail).
>>
>>I have a test program which looks like this:
>>
>>
>>     #include <stdlib.h>
>>     #include <unistd.h>
>>     #include <getopt.h>
>>     #include <sys/types.h>
>>     #include <sys/stat.h>
>>     #include <errno.h>
>>
>>     int main ( int argc, char **argv ) {
>>
>>         struct stat path_stats;
>>         int nRet = 0;
>>
>>         printf ( "%s\n", argv[1] );
>>         nRet = lstat ( argv[1], &path_stats );
>>         if ( nRet == -1 ) {
>>             printf ( "Return: %d: %s\n",
>>                     errno, strerror ( errno ) );
>>         }
>>
>>     }
>>
>>Basically, it's just doing an "lstat" of a file, and printing out
>>any problemss that occur.
>>
>>>From a directory
>>
>>    "e:/afsrc/tip12/funkware1/com/funkware/community/module/mpack/services/mpackgroup/uicomponents"
>>
>>i am doing:
>>    "a.exe ../../../../../../../../../WINNT4.0_DBG/funkware1/WEB-INF/classes/com/funkware/community/module/mpack/services/mpackgroup/uicomponents/UIPGrpSchResults.class"
>>
>>This file name is 157 characters long (much less than MAX_PATH
>>which is supposed to be 260).
>>
>>The program fails with an ENAMETOOLONG error.
>>
>>I've downloaded the latest snapshot: 20001213  (although I can't
>>seem to get it to build).  In looking through an strace output
>>(also included at the bottom of this file), I think that
>>"normalize_posix_path()" in winsup/cygwin/path.cc is verifying
>>the max path length improperly.  The offending code is at line
>>613 of path.cc (a clip is shown below).
>>
>>
>>    static int
>>    normalize_posix_path (const char *src, char *dst)
>>    {
>>      const char *src_start = src;
>>      char *dst_start = dst;
>>
>>      syscall_printf ("src %s", src);
>>      if (isdrive (src) || strpbrk (src, "\\:"))
>>        {
>>          cygwin_conv_to_full_posix_path (src, dst);
>>          return 0;
>>        }
>>      if (!isslash (src[0]))
>>        {
>>          if (!cygcwd.get (dst))
>>            return get_errno ();
>>
>>                /*
>>                 * This next line is the one in question...
>>                 */
>>          if (strlen (dst) + 1 + strlen (src) >= MAX_PATH)
>>
>>            {
>>              debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src);
>>              return ENAMETOOLONG;
>>            }
>>
>>the function is taking the length of both the destination and
>>source strings and seeing if they are greater than MAX_PATH.  Is
>>this a bug?  Or am I missing something here.  I apologize for not
>>being more sure, however I haven't been able to build the
>>library, and I can't get the latest gdb to look step into the
>>lstat call to really verify what's going on.
>
>"dst" in this case is the current working directory, so this is not
>wrong.  It's calculating the length of the current working directory +
>the length of a relative path.

Just to clarify.  The addition is not wrong because the length of dst is
being added to the length of src but the actual calculation does not take
any cleanup of ../ whatever into account.  This could probably be rectified.
I'll take a stab at checking something into CVS tonight.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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