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

Unified Diff: chrome/browser/shell_integration_linux.cc

Issue 614893004: Refactor AppendToFile and WriteFileDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 6 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
Index: chrome/browser/shell_integration_linux.cc
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index 905b23f07ced48adc233d82a5a8190acd653fcec..ef8f9b9272ab5bbc80e838192491df510e943170 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -163,12 +163,7 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename,
return false;
}
- ssize_t bytes_written = base::WriteFileDescriptor(fd, contents.data(),
- contents.length());
- if (IGNORE_EINTR(close(fd)) < 0)
- PLOG(ERROR) << "close";
-
- if (bytes_written != static_cast<ssize_t>(contents.length())) {
+ if (!base::WriteFileDescriptor(fd, contents.c_str(), contents.size())) {
// Delete the file. No shortuct is better than corrupted one. Use unlinkat
// to make sure we're deleting the file in the directory we think we are.
// Even if an attacker manager to put something other at
@@ -176,6 +171,9 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename,
unlinkat(desktop_fd, shortcut_filename.value().c_str(), 0);
}
+ if (IGNORE_EINTR(close(fd)) < 0)
+ PLOG(ERROR) << "close";
+
if (IGNORE_EINTR(close(desktop_fd)) < 0)
PLOG(ERROR) << "close";
« no previous file with comments | « chrome/browser/net/net_log_temp_file_unittest.cc ('k') | chromeos/process_proxy/process_output_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698