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

Unified Diff: base/base_paths_linux.cc

Issue 8361011: Tweak PathProviderPosix's FILE_EXE and FILE_MODULE handling on FreeBSD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed webkit/glue change Created 9 years, 2 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/base_paths_linux.cc
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc
index b082eb3b3d71e6811ed385541df2df7268d1bb0e..d1b56430f2ea42211bbb2bb7eb9700858c109de4 100644
--- a/base/base_paths_linux.cc
+++ b/base/base_paths_linux.cc
@@ -50,13 +50,14 @@ bool PathProviderPosix(int key, FilePath* result) {
int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
char bin_dir[PATH_MAX + 1];
size_t length = sizeof(bin_dir);
+ // Upon return, |length| is the number of bytes written to |bin_dir|
+ // including the string terminator.
int error = sysctl(name, 4, bin_dir, &length, NULL, 0);
- if (error < 0 || length == 0 || strlen(bin_dir) == 0) {
+ if (error < 0 || length <= 1) {
NOTREACHED() << "Unable to resolve path.";
return false;
}
- bin_dir[strlen(bin_dir)] = 0;
- *result = FilePath(bin_dir);
+ *result = FilePath(FilePath::StringType(bin_dir, length - 1));
return true;
#elif defined(OS_SOLARIS)
char bin_dir[PATH_MAX + 1];
« 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