Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6146)

Unified Diff: base/platform_file_win.cc

Issue 199843002: Require PLATFORM_FILE_BACKUP_SEMANTICS to open a directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/platform_file_win.cc
diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc
index 07b5c48c22bf1add6aaf77e93cb63a0ee36d6da7..b5e07d7665ffe6a9afa9fa184c39fafa4a3fafe9 100644
--- a/base/platform_file_win.cc
+++ b/base/platform_file_win.cc
@@ -86,6 +86,20 @@ PlatformFile CreatePlatformFileUnsafe(const FilePath& name,
HANDLE file = CreateFile(name.value().c_str(), access, sharing, NULL,
disposition, create_flags, NULL);
+ if (INVALID_HANDLE_VALUE != file){
Peter Kasting 2014/03/14 02:58:20 You didn't correct this style guide violation :(
+ // Don't allow directories to be opened without the proper flag (block ADS).
+ if (!(flags & PLATFORM_FILE_BACKUP_SEMANTICS)) {
+ BY_HANDLE_FILE_INFORMATION info = { 0 };
+ BOOL result = GetFileInformationByHandle(file, &info);
+ DCHECK(result);
+ if (info.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_REPARSE_POINT)) {
+ CloseHandle(file);
+ file = INVALID_HANDLE_VALUE;
+ }
+ }
+ }
+
if (created && (INVALID_HANDLE_VALUE != file)) {
if (flags & (PLATFORM_FILE_OPEN_ALWAYS))
*created = (ERROR_ALREADY_EXISTS != GetLastError());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698