Skip to content

Commit 9e8b6a1

Browse files
committed
<chromium> Cherry-pick fix for CVE-2015-6767
AppCache: Use WeakPtr<> to fix a potential uaf bug. BUG=554908 Review URL: https://codereview.chromium.org/1441683004 Change-Id: Ic5eb64a34a7e0d373428789b8571e6f3a2fc96e9 Reviewed-by: Michael Brüning <[email protected]>
1 parent d349835 commit 9e8b6a1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

chromium/content/browser/appcache/appcache_dispatcher_host.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ AppCacheDispatcherHost::AppCacheDispatcherHost(
1818
: BrowserMessageFilter(AppCacheMsgStart),
1919
appcache_service_(appcache_service),
2020
frontend_proxy_(this),
21-
process_id_(process_id) {
21+
process_id_(process_id),
22+
weak_factory_(this) {
2223
}
2324

2425
void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) {
@@ -27,13 +28,13 @@ void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) {
2728
appcache_service_.get(), &frontend_proxy_, process_id_);
2829
get_status_callback_ =
2930
base::Bind(&AppCacheDispatcherHost::GetStatusCallback,
30-
base::Unretained(this));
31+
weak_factory_.GetWeakPtr());
3132
start_update_callback_ =
3233
base::Bind(&AppCacheDispatcherHost::StartUpdateCallback,
33-
base::Unretained(this));
34+
weak_factory_.GetWeakPtr());
3435
swap_cache_callback_ =
3536
base::Bind(&AppCacheDispatcherHost::SwapCacheCallback,
36-
base::Unretained(this));
37+
weak_factory_.GetWeakPtr());
3738
}
3839
}
3940

chromium/content/browser/appcache/appcache_dispatcher_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "base/memory/ref_counted.h"
1111
#include "base/memory/scoped_ptr.h"
12+
#include "base/memory/weak_ptr.h"
1213
#include "base/process/process.h"
1314
#include "content/browser/appcache/appcache_backend_impl.h"
1415
#include "content/browser/appcache/appcache_frontend_proxy.h"
@@ -72,6 +73,8 @@ class AppCacheDispatcherHost : public BrowserMessageFilter {
7273
// The corresponding ChildProcessHost object's id().
7374
int process_id_;
7475

76+
base::WeakPtrFactory<AppCacheDispatcherHost> weak_factory_;
77+
7578
DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost);
7679
};
7780

0 commit comments

Comments
 (0)