wrowe 2003/09/17 12:07:30
Modified: . Tag: APR_0_9_BRANCH CHANGES
file_io/win32 Tag: APR_0_9_BRANCH filepath.c
test Tag: APR_0_9_BRANCH 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.
Backports
file_io/win32/filepath.c rev 1.44
test/testnames.c rev 1.17
Submitted by: Mike Pilato <[EMAIL PROTECTED]>, William Rowe
Revision Changes Path
No revision
No revision
1.426.2.1 +6 -2 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.426
retrieving revision 1.426.2.1
diff -u -r1.426 -r1.426.2.1
--- CHANGES 31 Aug 2003 16:28:54 -0000 1.426
+++ CHANGES 17 Sep 2003 19:07:30 -0000 1.426.2.1
@@ -1,11 +1,15 @@
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 <[EMAIL PROTECTED]>, William Rowe]
+
*) Work around a bug in Darwin when calling getnameinfo() on IPv4-mapped
IPv6-addresses. [Colm MacC�rthaigh <[EMAIL PROTECTED]>, Jeff Trawick,
Justin Erenkrantz]
*) Add apr_temp_dir_get() for getting the most suitable temp directory
- [CMike Pilato <[EMAIL PROTECTED]>, Thom May]
+ [Mike Pilato <[EMAIL PROTECTED]>, Thom May]
*) Modify apr_sockaddr_info_get to call the resolver when we
do not have a hostname. Also, fix bugs in the getaddrinfo()
@@ -1399,7 +1403,7 @@
[Mike Pilato <[EMAIL PROTECTED]>]
*) Add apr_open_stdout. This mirrors apr_open_stderr, except it works
- on stdout. [EMAIL PROTECTED]
+ on stdout. [Mike Pilato <[EMAIL PROTECTED]>]
*) Fix bug in file_io/unix/dir.c. There is no such thing as a dirent,
it must be a struct dirent.
No revision
No revision
1.42.2.1 +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.42
retrieving revision 1.42.2.1
diff -u -r1.42 -r1.42.2.1
--- filepath.c 25 Jun 2003 07:02:48 -0000 1.42
+++ filepath.c 17 Sep 2003 19:07:30 -0000 1.42.2.1
@@ -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 */
No revision
No revision
1.16.2.1 +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.16.2.1
diff -u -r1.16 -r1.16.2.1
--- testnames.c 8 Jan 2003 20:40:27 -0000 1.16
+++ testnames.c 17 Sep 2003 19:07:30 -0000 1.16.2.1
@@ -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)