diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-14 07:05:12 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-14 07:05:12 +0000 |
commit | cb4e2b590eff76446023ce2305d82b9487df64ae (patch) | |
tree | 601e4ac5687dbf5c696a4617d31ca9d6bc8da76d /win32 | |
parent | 104b5c7810b95741e45b5e01f7c557c96799c13e (diff) | |
download | ruby-cb4e2b590eff76446023ce2305d82b9487df64ae.tar.gz |
* win32/win32.c (check_valid_dir): reject "..." as directory name.
[Bug #6851]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index de655df8b3..7eaf1fc788 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4556,11 +4556,18 @@ check_valid_dir(const WCHAR *path) HANDLE fh; WCHAR full[MAX_PATH]; WCHAR *dmy; + WCHAR *p, *q; /* GetFileAttributes() determines "..." as directory. */ /* We recheck it by FindFirstFile(). */ - if (wcsstr(path, L"...") == NULL) + if (!(p = wcsstr(path, L"..."))) return 0; + q = p + wcsspn(p, L"."); + if ((p == path || wcschr(L":/\\", *(p - 1))) && + (!*q || wcschr(L":/\\", *q))) { + errno = ENOENT; + return -1; + } /* if the specified path is the root of a drive and the drive is empty, */ /* FindFirstFile() returns INVALID_HANDLE_VALUE. */ |