summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-03-03 04:32:11 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-03-03 04:32:11 (GMT)
commita0d9058325f3f9f666dedb54d330ac9a8f01eb7b (patch)
treebd0163f436ca325cf76fed96e1bc13acf023109d /generic
parent6c7e5a2b7ad325e8fdbbc938610a28b6bd713536 (diff)
downloadtcl-a0d9058325f3f9f666dedb54d330ac9a8f01eb7b.zip
tcl-a0d9058325f3f9f666dedb54d330ac9a8f01eb7b.tar.gz
tcl-a0d9058325f3f9f666dedb54d330ac9a8f01eb7b.tar.bz2
* generic/tclPathObj.c: Fix for failed normalization of
* tests/fileSystem.test: paths with /../ that lead back to the root of the filesystem, like /foo/.. [Bug 1379287].
Diffstat (limited to 'generic')
-rw-r--r--generic/tclPathObj.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 9ed241a..0cc577b 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPathObj.c,v 1.49 2006/01/12 18:35:28 vasiljevic Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.50 2006/03/03 04:32:11 dgp Exp $
*/
#include "tclInt.h"
@@ -309,12 +309,20 @@ TclFSNormalizeAbsolutePath(
* Either way, we now remove the last path element.
*/
- while (--curLen >= 0) {
+ while (--curLen > 0) {
if (IsSeparatorOrNull(linkStr[curLen])) {
Tcl_SetObjLength(retVal, curLen);
break;
}
}
+ if (curLen == 0) {
+ /* Attempt to .. beyond root becomes root: "/" */
+ if (dirSep[3] != 0) {
+ Tcl_SetObjLength(retVal, 0);
+ } else {
+ Tcl_SetObjLength(retVal, 1);
+ }
+ }
}
dirSep += 3;
oldDirSep = dirSep;