summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-09-13 14:26:26 (GMT)
committersebres <sebres@users.sourceforge.net>2024-09-13 14:26:26 (GMT)
commitf2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c (patch)
tree4b4c9c10fce59f32c11fad58a6bcc896c9f810dd /unix
parentbddda240611ea5ba0974d4e6d424c29f29f7057c (diff)
downloadtcl-f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c.zip
tcl-f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c.tar.gz
tcl-f2b14cb7f00034cf7c9ee3e5681e4c912ca7ff9c.tar.bz2
small amend: move the normalization to the block where the error message really neededcore-bug-02d5d65d70adab97
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixChan.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 1844a23..e072cd7 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -12,6 +12,7 @@
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
+#include "tclFileSystem.h"
#include "tclIO.h" /* To get Channel type declaration. */
#undef SUPPORTS_TTY
@@ -1418,6 +1419,24 @@ TclpOpenFileChannel(
native = (const char *)Tcl_FSGetNativePath(pathPtr);
if (native == NULL) {
if (interp != (Tcl_Interp *) NULL) {
+ /*
+ * We need this just to ensure we return the correct error messages under
+ * some circumstances (relative paths only), so because the normalization
+ * is very expensive, don't invoke it for native or absolute paths.
+ */
+ if (
+ (
+ (
+ !TclFSCwdIsNative() &&
+ (Tcl_FSGetPathType(pathPtr) != TCL_PATH_ABSOLUTE)
+ ) ||
+ (*TclGetString(pathPtr) == '~') /* possible tilde expansion */
+ ) &&
+ Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL
+ ) {
+ return NULL;
+ }
+
Tcl_AppendResult(interp, "couldn't open \"",
TclGetString(pathPtr), "\": filename is invalid on this platform",
(char *)NULL);