Index: chrome/installer/util/module_util_win.cc |
diff --git a/chrome/installer/util/module_util_win.cc b/chrome/installer/util/module_util_win.cc |
index c589263690a9c127ca795d8b75e3b449a2fdca6f..1c3facf74e3fafaeb2be6544e1892c62e758c42a 100644 |
--- a/chrome/installer/util/module_util_win.cc |
+++ b/chrome/installer/util/module_util_win.cc |
@@ -8,6 +8,7 @@ |
#include "base/file_version_info.h" |
#include "base/files/file.h" |
+#include "base/files/file_util.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/strings/utf_string_conversions.h" |
@@ -19,9 +20,17 @@ namespace { |
// Returns the directory in which the currently running executable resides. |
base::FilePath GetExecutableDir() { |
- base::char16 path[MAX_PATH]; |
- ::GetModuleFileNameW(nullptr, path, MAX_PATH); |
- return base::FilePath(path).DirName(); |
+ base::char16 path_buffer[MAX_PATH]; |
+ ::GetModuleFileNameW(nullptr, path_buffer, MAX_PATH); |
+ base::FilePath path(path_buffer); |
+ |
+ // When debugging Chrome from the gyp-generated Visual Studio solution, the |
gab
2015/11/12 18:10:30
You mean non-ninja builds? Those are not supported
fdoray
2015/11/12 18:27:23
When GYP_GENERATORS is set to "ninja,msvs-ninja",
|
+ // value returned by ::GetModuleFileNameW can contain a path traversal '..' |
+ // component, which isn't supported by base::File. |
+ if (path.ReferencesParent()) |
+ path = base::MakeAbsoluteFilePath(path); |
+ |
+ return path.DirName(); |
} |
// Returns the version in the current module's version resource or the empty |