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

Unified Diff: content/child/child_thread_impl.cc

Issue 2268603002: Avoid UAF on ConnectionFilter impls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | content/public/common/connection_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_thread_impl.cc
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
index 17dbafeeaf236eca74938ddfcb0fb8abfa7c035c..29454b64e1ab12feba98ce80e1d88bb66093b504 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -257,12 +257,10 @@ void InitializeMojoIPCChannel() {
mojo::edk::SetParentPipeHandle(std::move(platform_channel));
}
-class ChannelBootstrapFilter
- : public ConnectionFilter,
- public shell::InterfaceFactory<IPC::mojom::ChannelBootstrap> {
+class ChannelBootstrapFilter : public ConnectionFilter {
public:
explicit ChannelBootstrapFilter(IPC::mojom::ChannelBootstrapPtrInfo bootstrap)
- : bootstrap_(std::move(bootstrap)) {}
+ : bootstrap_(std::move(bootstrap)), weak_factory_(this) {}
private:
// ConnectionFilter:
@@ -272,18 +270,18 @@ class ChannelBootstrapFilter
if (remote_identity.name() != kBrowserMojoApplicationName)
return false;
- registry->AddInterface<IPC::mojom::ChannelBootstrap>(this);
+ registry->AddInterface(base::Bind(&ChannelBootstrapFilter::CreateBootstrap,
+ weak_factory_.GetWeakPtr()));
return true;
}
- // shell::InterfaceFactory<IPC::mojom::ChannelBootstrap>:
- void Create(const shell::Identity& remote_identity,
- IPC::mojom::ChannelBootstrapRequest request) override {
+ void CreateBootstrap(IPC::mojom::ChannelBootstrapRequest request) {
DCHECK(bootstrap_.is_valid());
mojo::FuseInterface(std::move(request), std::move(bootstrap_));
}
IPC::mojom::ChannelBootstrapPtrInfo bootstrap_;
+ base::WeakPtrFactory<ChannelBootstrapFilter> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ChannelBootstrapFilter);
};
« no previous file with comments | « no previous file | content/public/common/connection_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698