diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-02 08:59:56 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-02 08:59:56 (GMT) |
commit | 1e3394cc4fee92acebb7c79a7fb31aba9e1aab54 (patch) | |
tree | 84ad5e5324401e5fb231e9656e4bcecbb3387ae7 /win/tclWinFile.c | |
parent | 340a361ed19847861c47b986eb8d522c1a6cc700 (diff) | |
parent | 7ea92b545f09208376e9a9f8aa1aac53148f3f65 (diff) | |
download | tcl-1e3394cc4fee92acebb7c79a7fb31aba9e1aab54.zip tcl-1e3394cc4fee92acebb7c79a7fb31aba9e1aab54.tar.gz tcl-1e3394cc4fee92acebb7c79a7fb31aba9e1aab54.tar.bz2 |
merge novemnovem_bug_3598300
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 fbc4a3a..3bfde57 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); |