summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFile.c
diff options
context:
space:
mode:
authornijtmans@users.sourceforge.net <jan.nijtmans>2014-04-11 09:55:15 (GMT)
committernijtmans@users.sourceforge.net <jan.nijtmans>2014-04-11 09:55:15 (GMT)
commit45434cebe7201ee3ca73b3fb9be0ccf5bd44955e (patch)
tree9ff6ddc34e187c210a89e69f29a030ac35e35c91 /unix/tclUnixFile.c
parent8fcce4834c75c752f225247e602184d63102c6f1 (diff)
downloadtcl-45434cebe7201ee3ca73b3fb9be0ccf5bd44955e.zip
tcl-45434cebe7201ee3ca73b3fb9be0ccf5bd44955e.tar.gz
tcl-45434cebe7201ee3ca73b3fb9be0ccf5bd44955e.tar.bz2
Fix [3118489]: NUL in filenames, now fixed for both Windows and UNIX.
For consistancy, any NUL character in a filename prevents the native filesystem to generate a native file representation for it. Other filesystems than the native one may still accept it, but it's not recommended.
Diffstat (limited to 'unix/tclUnixFile.c')
-rw-r--r--unix/tclUnixFile.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 5bfe5d9..2cb0027 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1105,6 +1105,12 @@ TclNativeCreateNativeRep(
str = Tcl_GetStringFromObj(validPathPtr, &len);
Tcl_UtfToExternalDString(NULL, str, len, &ds);
len = Tcl_DStringLength(&ds) + sizeof(char);
+ if (strlen(Tcl_DStringValue(&ds)) < len - sizeof(char)) {
+ /* See bug [3118489]: NUL in filenames */
+ Tcl_DecrRefCount(validPathPtr);
+ Tcl_DStringFree(&ds);
+ return NULL;
+ }
Tcl_DecrRefCount(validPathPtr);
nativePathPtr = ckalloc(len);
memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len);