diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2013-03-19 11:48:34 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2013-03-19 11:48:34 (GMT) |
commit | 07682652147e5530be79285fe05c1fb40ee42069 (patch) | |
tree | 0ee3ddaf43365efce4a8279c870611e1c803337d | |
parent | 1fdd38f7039a6f414008a01436898a276c4e835d (diff) | |
download | tcl-bug_3608360.zip tcl-bug_3608360.tar.gz tcl-bug_3608360.tar.bz2 |
Check for wildcards if we've used FindFirstFile inside NativeAccess.bug_3608360
-rw-r--r-- | win/tclWinFile.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 18b05d6..7638ef2 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1538,15 +1538,26 @@ NativeAccess( */ WIN32_FIND_DATA ffd; - HANDLE hFind; - hFind = FindFirstFile(nativePath, &ffd); - if (hFind != INVALID_HANDLE_VALUE) { - attr = ffd.dwFileAttributes; - FindClose(hFind); - } else { + HANDLE hFind = FindFirstFile(nativePath, &ffd); + + if (hFind == INVALID_HANDLE_VALUE) { TclWinConvertError(GetLastError()); return -1; } + + attr = ffd.dwFileAttributes; + FindClose(hFind); + + /* + * Take care! Some characters are illegal in a filename, but legal in + * a search for a filename because they are wildcards. If there's one + * of those, we are still in an error case! [Bug 3608360] + */ + + if (_tcspbrk(nativePath, _T("?*")) != NULL) { + Tcl_SetErrno(EEXIST); + return -1; + } } if (mode == F_OK) { |