summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-11-03 12:54:25 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-11-03 12:54:25 (GMT)
commit5b84b16e1fee2a7da08f3e3a3f0bb7a0ea5a72a8 (patch)
tree108eb7029d3260cbad294cd97c09a6c18b50cf39
parentaa12aa72b9b56351ec474068517b61c5489a5cf2 (diff)
parentbce5edef8b197d622f6f22b25021afd987743698 (diff)
downloadtcl-5b84b16e1fee2a7da08f3e3a3f0bb7a0ea5a72a8.zip
tcl-5b84b16e1fee2a7da08f3e3a3f0bb7a0ea5a72a8.tar.gz
tcl-5b84b16e1fee2a7da08f3e3a3f0bb7a0ea5a72a8.tar.bz2
Add test-case for previous commit, which shows that when trying to open a filename with invalid characters gives the right error-message. (same bug existed on UNIX too, which is now fixed)
-rw-r--r--tests/fileSystem.test3
-rw-r--r--unix/tclUnixChan.c5
2 files changed, 8 insertions, 0 deletions
diff --git a/tests/fileSystem.test b/tests/fileSystem.test
index 942a86c..9fe4fe9 100644
--- a/tests/fileSystem.test
+++ b/tests/fileSystem.test
@@ -513,6 +513,9 @@ test filesystem-6.32 {empty file name} -returnCodes error -body {
file type ""
} -result {could not read "": no such file or directory}
test filesystem-6.33 {empty file name} {file writable ""} 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 fdc9d1d..2eca714 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -1361,6 +1361,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;
}