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

Unified Diff: chrome/installer/util/module_util_win.cc

Issue 1436103005: Use PathService in installer::GetModulePath(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: 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
« 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