summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-11-03 20:54:12 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-11-03 20:54:12 (GMT)
commit5a0bdb1baf6c35b490aa2d34d5ea5aec3ae66831 (patch)
tree02a53669abb63933d41502ab5ab8be25d962b193
parentc40bcd39bfbe1d61ef75fd3cc9a6604b6cd20193 (diff)
parentbce5edef8b197d622f6f22b25021afd987743698 (diff)
downloadtcl-5a0bdb1baf6c35b490aa2d34d5ea5aec3ae66831.zip
tcl-5a0bdb1baf6c35b490aa2d34d5ea5aec3ae66831.tar.gz
tcl-5a0bdb1baf6c35b490aa2d34d5ea5aec3ae66831.tar.bz2
merge 8.5
-rw-r--r--tests/fileSystem.test3
-rw-r--r--unix/tclUnixChan.c5
-rw-r--r--win/tclWinChan.c5
-rw-r--r--win/tclWinFile.c9
4 files changed, 19 insertions, 3 deletions
diff --git a/tests/fileSystem.test b/tests/fileSystem.test
index 161ebc3..c255b1e 100644
--- a/tests/fileSystem.test
+++ b/tests/fileSystem.test
@@ -708,6 +708,9 @@ test filesystem-6.32 {empty file name} {
test filesystem-6.33 {empty file name} {
list [catch {file writable ""} msg] $msg
} {0 0}
+test filesystem-6.34 {file name with (invalid) nul character} {
+ list [catch "open foo\x00" msg] $msg
+} [list 1 "couldn't open \"foo\x00\": filename is invalid on this platform"]
# Make sure the testfilesystem hasn't been registered.
if {[testConstraint testfilesystem]} {
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 1d60340..89c9a27 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -1647,6 +1647,11 @@ TclpOpenFileChannel(
native = Tcl_FSGetNativePath(pathPtr);
if (native == NULL) {
+ if (interp != (Tcl_Interp *) NULL) {
+ Tcl_AppendResult(interp, "couldn't open \"",
+ TclGetString(pathPtr), "\": filename is invalid on this platform",
+ NULL);
+ }
return NULL;
}
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index 6d480a8..a271919 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -840,6 +840,11 @@ TclpOpenFileChannel(
nativeName = (TCHAR*) Tcl_FSGetNativePath(pathPtr);
if (nativeName == NULL) {
+ if (interp != (Tcl_Interp *) NULL) {
+ Tcl_AppendResult(interp, "couldn't open \"",
+ TclGetString(pathPtr), "\": filename is invalid on this platform",
+ NULL);
+ }
return NULL;
}
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 9bf63b1..7487022 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -1225,9 +1225,9 @@ WinIsReserved(
if ((path[0] == 'c' || path[0] == 'C')
&& (path[1] == 'o' || path[1] == 'O')) {
if ((path[2] == 'm' || path[2] == 'M')
- && path[3] >= '1' && path[3] <= '4') {
+ && path[3] >= '1' && path[3] <= '9') {
/*
- * May have match for 'com[1-4]:?', which is a serial port.
+ * May have match for 'com[1-9]:?', which is a serial port.
*/
if (path[4] == '\0') {
@@ -3203,7 +3203,10 @@ TclNativeCreateNativeRep(
Tcl_WinUtfToTChar(str, len, &ds);
if (tclWinProcs->useWide) {
WCHAR *wp = (WCHAR *) Tcl_DStringValue(&ds);
- len = Tcl_DStringLength(&ds)>>1;
+ /* For a reserved device, strip a possible postfix ':' */
+ len = WinIsReserved(str);
+ /* For normal devices */
+ if (len == 0) len = Tcl_DStringLength(&ds)>>1;
/*
** If path starts with "//?/" or "\\?\" (extended path), translate
** any slashes to backslashes but accept the '?' as being valid.