summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFile.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-05-15 14:54:45 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-05-15 14:54:45 (GMT)
commit47b1f4425678fcc051e9a75f59f6c4cd4f21b176 (patch)
treecdbc77bc0588dd7ed0f06b4d9250ebb889dbb7d1 /unix/tclUnixFile.c
parent5e610145644e54a301c3f508b6c6fb4dcf95f7b6 (diff)
downloadtcl-47b1f4425678fcc051e9a75f59f6c4cd4f21b176.zip
tcl-47b1f4425678fcc051e9a75f59f6c4cd4f21b176.tar.gz
tcl-47b1f4425678fcc051e9a75f59f6c4cd4f21b176.tar.bz2
Fix [3118489]: NUL in filenames. (On Windows, protect against invalid use of ':' in filenames as well)
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 29f1aba..c5f75a7 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1111,6 +1111,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((unsigned) len);
memcpy((void*)nativePathPtr, (void*)Tcl_DStringValue(&ds), (size_t) len);