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

Unified Diff: chrome/common/multi_process_lock_linux.cc

Issue 5100001: Fix up clang build, and presubmit warnings about strcpy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up signed/unsigned compare Created 10 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 | chrome/common/multi_process_lock_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/multi_process_lock_linux.cc
diff --git a/chrome/common/multi_process_lock_linux.cc b/chrome/common/multi_process_lock_linux.cc
index 0a83c8976ffc021de80babdeeaf4241a4e1af840..d2d3da331ca6864919e9364495aa200bcd08b413 100644
--- a/chrome/common/multi_process_lock_linux.cc
+++ b/chrome/common/multi_process_lock_linux.cc
@@ -43,7 +43,15 @@ class MultiProcessLockLinux : public MultiProcessLock {
== MULTI_PROCESS_LOCK_NAME_MAX_LEN + 2, sun_path_size_changed);
memset(&address, 0, sizeof(address));
- strcpy(&address.sun_path[1], name_.c_str());
+ int print_length = snprintf(&address.sun_path[1],
+ MULTI_PROCESS_LOCK_NAME_MAX_LEN + 1,
+ "%s", name_.c_str());
+
+ if (print_length < 0 ||
+ print_length > static_cast<int>(MULTI_PROCESS_LOCK_NAME_MAX_LEN)) {
+ PLOG(ERROR) << "Couldn't create sun_path - " << name_;
+ return false;
+ }
// Must set the first character of the path to something non-zero
// before we call SUN_LEN which depends on strcpy working.
@@ -70,7 +78,9 @@ class MultiProcessLockLinux : public MultiProcessLock {
PLOG(ERROR) << "Couldn't bind socket - "
<< &(address.sun_path[1])
<< " Length: " << length;
- HANDLE_EINTR(close(socket_fd));
+ if (HANDLE_EINTR(close(socket_fd)) < 0) {
+ PLOG(ERROR) << "close";
+ }
return false;
}
}
@@ -80,7 +90,9 @@ class MultiProcessLockLinux : public MultiProcessLock {
DLOG(ERROR) << "Over-unlocked MultiProcessLock - " << name_;
return;
}
- HANDLE_EINTR(close(fd_));
+ if (HANDLE_EINTR(close(fd_)) < 0) {
+ PLOG(ERROR) << "close";
+ }
fd_ = -1;
}
« no previous file with comments | « no previous file | chrome/common/multi_process_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698