diff options
author | dgp <dgp@users.sourceforge.net> | 2003-11-05 20:52:38 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2003-11-05 20:52:38 (GMT) |
commit | e5199821f0f325aaab89027b511707191fbe2b67 (patch) | |
tree | b9b6cfff34bf9f514e751d6b1bdedf8ff7de4c0f | |
parent | 27b9197dbd4ae5800d5d7745077b33b95a610160 (diff) | |
download | tcl-e5199821f0f325aaab89027b511707191fbe2b67.zip tcl-e5199821f0f325aaab89027b511707191fbe2b67.tar.gz tcl-e5199821f0f325aaab89027b511707191fbe2b67.tar.bz2 |
* generic/tclEncoding.c (TclFindEncodings): Normalize the path
of the executable before passing to TclpInitLibraryPath() to avoid
buggy handling of paths containing "..". [Bug 832657]
* tests/unixInit.test (unixInit-2.10): New test for fixed bug.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tclEncoding.c | 14 | ||||
-rw-r--r-- | tests/unixInit.test | 36 |
3 files changed, 51 insertions, 6 deletions
@@ -1,3 +1,10 @@ +2003-11-05 Don Porter <dgp@users.sourceforge.net> + + * generic/tclEncoding.c (TclFindEncodings): Normalize the path + of the executable before passing to TclpInitLibraryPath() to avoid + buggy handling of paths containing "..". [Bug 832657] + * tests/unixInit.test (unixInit-2.10): New test for fixed bug. + 2003-11-04 Daniel Steffen <das@users.sourceforge.net> * macosx/Makefile: added 'test' target. diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 576a479..87f4669 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEncoding.c,v 1.16 2003/02/21 02:40:58 hobbs Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.16.2.1 2003/11/05 20:52:39 dgp Exp $ */ #include "tclInt.h" @@ -2827,8 +2827,7 @@ TclFindEncodings(argv0) CONST char *argv0; /* Name of executable from argv[0] to main() * in native multi-byte encoding. */ { - char *native; - Tcl_Obj *pathPtr; + Tcl_Obj *pathPtr, *normPtr; Tcl_DString libPath, buffer; if (encodingsInitialized == 0) { @@ -2846,8 +2845,13 @@ TclFindEncodings(argv0) encodingsInitialized = 1; - native = TclpFindExecutable(argv0); - TclpInitLibraryPath(native); + pathPtr = Tcl_NewStringObj(TclpFindExecutable(argv0), -1); + Tcl_IncrRefCount(pathPtr); + normPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr); + Tcl_IncrRefCount(normPtr); + Tcl_DecrRefCount(pathPtr); + TclpInitLibraryPath(Tcl_GetString(normPtr)); + Tcl_DecrRefCount(normPtr); /* * The library path was set in the TclpInitLibraryPath routine. diff --git a/tests/unixInit.test b/tests/unixInit.test index 0f01943..4c1b37e 100644 --- a/tests/unixInit.test +++ b/tests/unixInit.test @@ -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: unixInit.test,v 1.30 2002/12/04 07:07:40 hobbs Exp $ +# RCS: @(#) $Id: unixInit.test,v 1.30.2.1 2003/11/05 20:52:39 dgp Exp $ package require tcltest 2 namespace import -force ::tcltest::* @@ -266,6 +266,40 @@ test unixInit-2.9 {TclpInitLibraryPath: paths relative to executable} {unix noSp set x } [list /tmp/lib/tcl[info tclversion] /lib/tcl[info tclversion] \ /tmp/library /library /tcl[info patchlevel]/library] + +test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints { + unixOnly stdio +} -setup { + set tmpDir [makeDirectory tmp] + set sparklyDir [makeDirectory sparkly $tmpDir] + set execPath [file join [makeDirectory bin $sparklyDir] tcltest] + file copy [interpreter] $execPath + set libDir [makeDirectory lib $sparklyDir] + set scriptDir [makeDirectory tcl[info tclversion] $libDir] + makeFile {} init.tcl $scriptDir + set saveDir [pwd] + cd $libDir +} -body { + # Checking for Bug 832657 + lrange [getlibpath [file join .. bin tcltest]] 2 3 +} -cleanup { + cd $saveDir + unset saveDir + removeFile init.tcl $scriptDir + unset scriptDir + removeDirectory tcl[info tclversion] $libDir + unset libDir + file delete $execPath + unset execPath + removeDirectory bin $sparklyDir + removeDirectory lib $sparklyDir + unset sparklyDir + removeDirectory sparkly $tmpDir + unset tmpDir + removeDirectory tmp +} -result [list [file join [temporaryDirectory] tmp sparkly library] \ + [file join [temporaryDirectory] tmp library] ] + test unixInit-3.1 {TclpSetInitialEncodings} -constraints { unixOnly stdio } -body { |