You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2003/09/17 21:05:44 UTC

cvs commit: apr/test testnames.c

wrowe       2003/09/17 12:05:44

  Modified:    .        CHANGES
               file_io/win32 filepath.c
               test     testnames.c
  Log:
    Preserve leading '../' segments as when merging to an empty and
    unrooted path - fixes a bug observed in SVN with Win32/Netware/OS2.
  
  Submitted by:	Mike Pilato <cm...@collab.net>, William Rowe
  
  Revision  Changes    Path
  1.433     +6 -2      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.432
  retrieving revision 1.433
  diff -u -r1.432 -r1.433
  --- CHANGES	5 Sep 2003 16:44:09 -0000	1.432
  +++ CHANGES	17 Sep 2003 19:05:43 -0000	1.433
  @@ -63,12 +63,16 @@
   
   Changes with APR 0.9.4
   
  +  *) Preserve leading '../' segments as when merging to an empty and
  +     unrooted path - fixes a bug observed in SVN with Win32/Netware/OS2.
  +     [Mike Pilato <cm...@collab.net>, William Rowe]
  +
     *) Work around a bug in Darwin when calling getnameinfo() on IPv4-mapped
        IPv6-addresses.  [Colm MacC�rthaigh <co...@stdlib.net>, Jeff Trawick,
        Justin Erenkrantz]
   
     *) Add apr_temp_dir_get() for getting the most suitable temp directory
  -     [CMike Pilato <cm...@collab.net>, Thom May]
  +     [Mike Pilato <cm...@collab.net>, Thom May]
   
     *) Modify apr_sockaddr_info_get to call the resolver when we
        do not have a hostname.  Also, fix bugs in the getaddrinfo()
  @@ -1462,7 +1466,7 @@
        [Mike Pilato <cm...@collab.net>] 
     
     *) Add apr_open_stdout.  This mirrors apr_open_stderr, except it works
  -     on stdout.  [cmpilato@collab.net]
  +     on stdout.  [Mike Pilato <cm...@collab.net>]
   
     *) Fix bug in file_io/unix/dir.c.  There is no such thing as a dirent,
        it must be a struct dirent.  
  
  
  
  1.44      +17 -12    apr/file_io/win32/filepath.c
  
  Index: filepath.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filepath.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- filepath.c	3 Sep 2003 18:26:57 -0000	1.43
  +++ filepath.c	17 Sep 2003 19:05:43 -0000	1.44
  @@ -706,8 +706,8 @@
                   return APR_EBADPATH;
   #endif
   
  -            /* backpath (../) */
  -            if (pathlen <= rootlen) 
  +            /* backpath (../) when an absolute path is given */
  +            if (rootlen && (pathlen <= rootlen)) 
               {
                   /* Attempt to move above root.  Always die if the 
                    * APR_FILEPATH_SECUREROOTTEST flag is specified.
  @@ -736,9 +736,14 @@
                    */
                   if (pathlen + 3 >= sizeof(path))
                       return APR_ENAMETOOLONG;
  -                memcpy(path + pathlen, ((flags && APR_FILEPATH_NATIVE) 
  +                memcpy(path + pathlen, ((flags & APR_FILEPATH_NATIVE) 
                                             ? "..\\" : "../"), 3);
                   pathlen += 3;
  +                /* The 'root' part of this path now includes the ../ path,
  +                 * because that backpath will not be parsed by the truename
  +                 * code below.
  +                 */
  +                keptlen = pathlen;
               }
               else 
               {
  @@ -748,16 +753,16 @@
                       --pathlen;
                   } while (pathlen && path[pathlen - 1] != '/'
                                    && path[pathlen - 1] != '\\');
  -            }
   
  -            /* Now test if we are above where we started and back up
  -             * the keptlen offset to reflect the added/altered path.
  -             */
  -            if (pathlen < keptlen) 
  -            {
  -                if (flags & APR_FILEPATH_SECUREROOTTEST)
  -                    return APR_EABOVEROOT;
  -                keptlen = pathlen;
  +                /* Now test if we are above where we started and back up
  +                 * the keptlen offset to reflect the added/altered path.
  +                 */
  +                if (pathlen < keptlen) 
  +                {
  +                    if (flags & APR_FILEPATH_SECUREROOTTEST)
  +                        return APR_EABOVEROOT;
  +                    keptlen = pathlen;
  +                }
               }
           }
           else /* not empty or dots */
  
  
  
  1.17      +13 -0     apr/test/testnames.c
  
  Index: testnames.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testnames.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- testnames.c	8 Jan 2003 20:40:27 -0000	1.16
  +++ testnames.c	17 Sep 2003 19:05:43 -0000	1.17
  @@ -114,6 +114,19 @@
       CuAssertPtrNotNull(tc, dstpath);
       CuAssertIntEquals(tc, APR_SUCCESS, rv);
       CuAssertStrEquals(tc, ABS_ROOT"foo/baz", dstpath);
  +
  +    rv = apr_filepath_merge(&dstpath, "", "../test", 0, p);
  +    CuAssertIntEquals(tc, 0, APR_SUCCESS);
  +    CuAssertStrEquals(tc, "../test", dstpath);
  +
  +    /* Very dangerous assumptions here about what the cwd is.  However, let's assume
  +     * that the testall is invoked from within apr/test/ so the following test should
  +     * return ../test unless a previously fixed bug remains or the developer changes
  +     * the case of the test directory:
  +     */
  +    rv = apr_filepath_merge(&dstpath, "", "../test", APR_FILEPATH_TRUENAME, p);
  +    CuAssertIntEquals(tc, 0, APR_SUCCESS);
  +    CuAssertStrEquals(tc, "../test", dstpath);
   }
   
   static void merge_secure(CuTest *tc)