diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-04-11 09:55:15 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-04-11 09:55:15 (GMT) |
commit | 7fb053c9643440e5075f5e513853c9efff0ae44d (patch) | |
tree | 9ff6ddc34e187c210a89e69f29a030ac35e35c91 /win/tclWinFile.c | |
parent | 09e3a3c56b5d44c637c6ed0593257e51461e8861 (diff) | |
download | tcl-7fb053c9643440e5075f5e513853c9efff0ae44d.zip tcl-7fb053c9643440e5075f5e513853c9efff0ae44d.tar.gz tcl-7fb053c9643440e5075f5e513853c9efff0ae44d.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 'win/tclWinFile.c')
-rw-r--r-- | win/tclWinFile.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index c9b95a0..fc0ac9e 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1816,6 +1816,9 @@ TclpObjChdir( nativePath = Tcl_FSGetNativePath(pathPtr); + if (!nativePath) { + return -1; + } result = SetCurrentDirectory(nativePath); if (result == 0) { @@ -2929,6 +2932,12 @@ TclNativeCreateNativeRep( wp = (WCHAR *) Tcl_DStringValue(&ds); for (i=sizeof(WCHAR); i<len; ++wp,i+=sizeof(WCHAR)) { if ( (*wp < ' ') || wcschr(L"\"*<>|", *wp) ){ + if (!*wp){ + /* See bug [3118489]: NUL in filenames */ + Tcl_DecrRefCount(validPathPtr); + Tcl_DStringFree(&ds); + return NULL; + } *wp |= 0xF000; }else if (*wp=='/') { *wp = '\\'; |