From c0e895e2961bd05570b0d7660016914601bf8c7d Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Fri, 14 Mar 2014 19:36:50 +0000 Subject: Implement ScopedFD in terms of ScopedGeneric. Move to a new file base/files/scoped_file.h. I will also add ScopedFILE to here (currently in file_util.h) later. I think there is a crash in the old code in content/browser/zygote_host/zygote_host_impl_linux.cc that this patch should fix. The old ScopedFD took the address of something in a vector that is being modified. I removed SafeScopedFD from content/common/sandbox_linux/sandbox_linux.cc since base's ScopedFD not CHECKs on close failure (this is a more recent addition). BUG= R=agl@chromium.org, viettrungluu@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257001 Review URL: https://codereview.chromium.org/191673003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257179 0039d316-1c4b-4281-b951-d872f2087c98 --- ipc/ipc_channel_factory.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ipc/ipc_channel_factory.cc') diff --git a/ipc/ipc_channel_factory.cc b/ipc/ipc_channel_factory.cc index 5c24284..244024c 100644 --- a/ipc/ipc_channel_factory.cc +++ b/ipc/ipc_channel_factory.cc @@ -5,6 +5,7 @@ #include "ipc/ipc_channel_factory.h" #include "base/file_util.h" +#include "base/files/scoped_file.h" #include "base/logging.h" #include "ipc/unix_domain_socket_util.h" @@ -51,21 +52,20 @@ void ChannelFactory::OnFileCanReadWithoutBlocking(int fd) { delegate_->OnListenError(); return; } + base::ScopedFD scoped_fd(new_fd); - if (new_fd < 0) { + if (!scoped_fd.is_valid()) { // The accept() failed, but not in such a way that the factory needs to be // shut down. return; } - file_util::ScopedFD scoped_fd(&new_fd); - // Verify that the IPC channel peer is running as the same user. - if (!IsPeerAuthorized(new_fd)) + if (!IsPeerAuthorized(scoped_fd.get())) return; ChannelHandle handle(std::string(), - base::FileDescriptor(*scoped_fd.release(), true)); + base::FileDescriptor(scoped_fd.release(), true)); delegate_->OnClientConnected(handle); } -- cgit v1.1