diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-04-15 10:46:23 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-04-15 10:46:23 (GMT) |
commit | 13aaf9c46acb147461bc3f09089c575d4af087d0 (patch) | |
tree | 2e730303ac5a9123665101be96e596e006d88753 /win/tclWinFile.c | |
parent | b548441f399cf039b31e3f120b693ec61e574e7f (diff) | |
parent | 363b6911107557283c7fec07e041e14c7af7eee3 (diff) | |
download | tcl-13aaf9c46acb147461bc3f09089c575d4af087d0.zip tcl-13aaf9c46acb147461bc3f09089c575d4af087d0.tar.gz tcl-13aaf9c46acb147461bc3f09089c575d4af087d0.tar.bz2 |
merge trunk
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r-- | win/tclWinFile.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index f69ad23..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) { @@ -2897,7 +2900,8 @@ TclNativeCreateNativeRep( char *nativePathPtr, *str; Tcl_DString ds; Tcl_Obj *validPathPtr; - int len; + int len, i = 2; + WCHAR *wp; if (TclFSCwdIsNative()) { /* @@ -2923,17 +2927,22 @@ TclNativeCreateNativeRep( } str = Tcl_GetStringFromObj(validPathPtr, &len); - if (str[0] == '/' && str[1] == '/' && str[2] == '?' && str[3] == '/') { - char *p; - - for (p = str; p && *p; ++p) { - if (*p == '/') { - *p = '\\'; + Tcl_WinUtfToTChar(str, len, &ds); + len = Tcl_DStringLength(&ds) + sizeof(WCHAR); + 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 = '\\'; } } - Tcl_WinUtfToTChar(str, len, &ds); - len = Tcl_DStringLength(&ds) + sizeof(WCHAR); Tcl_DecrRefCount(validPathPtr); nativePathPtr = ckalloc(len); memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len); |