From cvs-return-5136-apmail-apr-cvs-archive=apr.apache.org@apr.apache.org Wed Sep 17 19:06:07 2003 Return-Path: Delivered-To: apmail-apr-cvs-archive@www.apache.org Received: (qmail 96229 invoked from network); 17 Sep 2003 19:06:07 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 17 Sep 2003 19:06:07 -0000 Received: (qmail 33631 invoked by uid 500); 17 Sep 2003 19:05:35 -0000 Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 33583 invoked by uid 500); 17 Sep 2003 19:05:34 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 33569 invoked from network); 17 Sep 2003 19:05:34 -0000 Date: 17 Sep 2003 19:05:44 -0000 Message-ID: <20030917190544.96083.qmail@minotaur.apache.org> From: wrowe@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/test testnames.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 , 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 , William Rowe] + *) Work around a bug in Darwin when calling getnameinfo() on IPv4-mapped IPv6-addresses. [Colm MacCárthaigh , Jeff Trawick, Justin Erenkrantz] *) Add apr_temp_dir_get() for getting the most suitable temp directory - [CMike Pilato , Thom May] + [Mike Pilato , 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 ] *) Add apr_open_stdout. This mirrors apr_open_stderr, except it works - on stdout. [cmpilato@collab.net] + on stdout. [Mike Pilato ] *) 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)