This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Possible Bug in file length calculation in normalize_posix_path


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.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]