Added key_session_ guard to SelectKey.
[ Merge of http://go/wvgerrit/146329 ] A rare race condition was found where a key is selected as the session is closed. This results in a null pointer dereference in CryptoSession::SelectKey(). Two additional checks have been added to SelectKey() to prevent this from occuring. Bug: 217749078 Test: CDM unit tests, atest GtsMediaTestCases Change-Id: Iec390cc7d1f28ddc18a30a68bc78922ec4fdbb89
This commit is contained in:
@@ -1391,7 +1391,9 @@ CdmResponseType CryptoSession::LoadCertificatePrivateKey(
|
||||
// Private.
|
||||
CdmResponseType CryptoSession::SelectKey(const std::string& key_id,
|
||||
CdmCipherMode cipher_mode) {
|
||||
RETURN_IF_NOT_OPEN(CRYPTO_SESSION_NOT_OPEN);
|
||||
const OEMCryptoResult sts = WithOecSessionLock("SelectKey", [&] {
|
||||
RETURN_IF_NULL(key_session_, OEMCrypto_ERROR_INVALID_SESSION);
|
||||
return key_session_->SelectKey(key_id, cipher_mode);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user