diff options
author | sacomoto <sacomoto@chromium.org> | 2015-07-12 08:16:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-12 15:17:29 +0000 |
commit | 059d385db83cd411eacceffe486c34a903879020 (patch) | |
tree | 7a954b341e3566e45a066882dd267469a9c1e14c /components/proximity_auth | |
parent | 4a045d3f48f6d4e19414f6d24a62a61d1e7cac29 (diff) | |
download | chromium_src-059d385db83cd411eacceffe486c34a903879020.zip chromium_src-059d385db83cd411eacceffe486c34a903879020.tar.gz chromium_src-059d385db83cd411eacceffe486c34a903879020.tar.bz2 |
Adding a double unlock guard in ProximityAuthBleSystem.
A double call to |screenlock_bridge_->Unlock()| seems to cause a memory
corruption.
BUG=507276
Review URL: https://codereview.chromium.org/1227103005
Cr-Commit-Position: refs/heads/master@{#338454}
Diffstat (limited to 'components/proximity_auth')
-rw-r--r-- | components/proximity_auth/ble/proximity_auth_ble_system.cc | 7 | ||||
-rw-r--r-- | components/proximity_auth/ble/proximity_auth_ble_system.h | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.cc b/components/proximity_auth/ble/proximity_auth_ble_system.cc index aa3f8da..0ff9653 100644 --- a/components/proximity_auth/ble/proximity_auth_ble_system.cc +++ b/components/proximity_auth/ble/proximity_auth_ble_system.cc @@ -93,6 +93,7 @@ ProximityAuthBleSystem::ProximityAuthBleSystem( cryptauth_client_factory_(cryptauth_client_factory.Pass()), device_whitelist_(new BluetoothLowEnergyDeviceWhitelist(pref_service)), device_authenticated_(false), + unlock_requested_(false), is_polling_screen_state_(false), weak_ptr_factory_(this) { PA_LOG(INFO) << "Starting Proximity Auth over Bluetooth Low Energy."; @@ -104,6 +105,7 @@ ProximityAuthBleSystem::ProximityAuthBleSystem( ProximityAuthClient* proximity_auth_client) : screenlock_bridge_(screenlock_bridge.Pass()), proximity_auth_client_(proximity_auth_client), + unlock_requested_(false), is_polling_screen_state_(false), weak_ptr_factory_(this) { PA_LOG(INFO) << "Starting Proximity Auth over Bluetooth Low Energy."; @@ -188,6 +190,7 @@ void ProximityAuthBleSystem::OnScreenDidLock( break; case ScreenlockBridge::LockHandler::LOCK_SCREEN: DCHECK(!connection_finder_); + unlock_requested_ = false; connection_finder_.reset(CreateConnectionFinder()); connection_finder_->Find( base::Bind(&ProximityAuthBleSystem::OnConnectionFound, @@ -225,6 +228,7 @@ void ProximityAuthBleSystem::OnScreenDidUnlock( device_authenticated_ = false; } + unlock_requested_ = false; connection_.reset(); connection_finder_.reset(); } @@ -268,9 +272,10 @@ void ProximityAuthBleSystem::OnMessageReceived(const Connection& connection, // Note that this magically unlocks Chrome (no user interaction is needed). // This user experience for this operation will be greately improved once // the Proximity Auth Unlock Manager migration to C++ is done. - if (message.payload() == kScreenUnlocked) { + if (message.payload() == kScreenUnlocked && !unlock_requested_) { PA_LOG(INFO) << "Device unlocked. Unlock."; screenlock_bridge_->Unlock(proximity_auth_client_); + unlock_requested_ = true; } } diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.h b/components/proximity_auth/ble/proximity_auth_ble_system.h index 34d4b2c..f40c9f2 100644 --- a/components/proximity_auth/ble/proximity_auth_ble_system.h +++ b/components/proximity_auth/ble/proximity_auth_ble_system.h @@ -135,8 +135,15 @@ class ProximityAuthBleSystem : public ScreenlockBridge::Observer, const base::TimeDelta polling_interval_; + // True if the remote device sent public key contained in |unlock_keyes_| or + // |device_whitelist_|. bool device_authenticated_; + // True if the screen is locked and call to |screenlock_bridge_->Unlock()| was + // made, but |OnScreenDidUnlock| was not called yet. This is a guard to avoid + // a double |screenlock_bridge_->Unlock()| call. + bool unlock_requested_; + bool is_polling_screen_state_; base::WeakPtrFactory<ProximityAuthBleSystem> weak_ptr_factory_; |