diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-15 14:54:45 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-15 14:54:45 (GMT) |
commit | 47b1f4425678fcc051e9a75f59f6c4cd4f21b176 (patch) | |
tree | cdbc77bc0588dd7ed0f06b4d9250ebb889dbb7d1 /unix | |
parent | 5e610145644e54a301c3f508b6c6fb4dcf95f7b6 (diff) | |
download | tcl-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')
-rw-r--r-- | unix/tclUnixFile.c | 6 |
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); |