Replacing NULL with nullptr in core/
[ Merge of http://go/wvgerrit/84647 ] [ Merge of http://go/wvgerrit/84648 ] Replacing most instances of C's NULL with C++'s nullptr. Also changed how a NULL check is performed on smart pointers. They provided an implicit boolean operator for null checks, meaning the underlying pointer does not need to be compared directly (as it was in some places before). Note that clang-format has performed additional changes to some of the test files that have not yet been formatted. Bug: 120602075 Test: Linux and Android unittests Change-Id: I06ddebe34b0ea6dfecedb5527e7e808e32f5269a
This commit is contained in:
@@ -27,7 +27,7 @@ namespace wvcdm {
|
||||
class BufferReader {
|
||||
public:
|
||||
BufferReader(const uint8_t* buf, size_t size)
|
||||
: buf_(buf), size_(buf != NULL ? size : 0), pos_(0) {}
|
||||
: buf_(buf), size_(buf != nullptr ? size : 0), pos_(0) {}
|
||||
|
||||
bool HasBytes(size_t count) const { return pos_ + count <= size_; }
|
||||
bool IsEOF() const { return pos_ >= size_; }
|
||||
|
||||
@@ -151,7 +151,7 @@ class CdmSession {
|
||||
virtual bool is_temporary() { return is_temporary_; }
|
||||
virtual bool license_received() { return license_received_; }
|
||||
virtual bool has_provider_session_token() {
|
||||
return (license_parser_.get() != NULL &&
|
||||
return (license_parser_ &&
|
||||
license_parser_->provider_session_token().size() > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class CdmLicense {
|
||||
virtual CdmResponseType RestoreLicenseForRelease(
|
||||
const CdmKeyMessage& license_request,
|
||||
const CdmKeyResponse& license_response);
|
||||
virtual bool HasInitData() { return stored_init_data_.get(); }
|
||||
virtual bool HasInitData() { return static_cast<bool>(stored_init_data_); }
|
||||
virtual bool IsKeyLoaded(const KeyId& key_id);
|
||||
|
||||
virtual std::string provider_session_token() {
|
||||
|
||||
@@ -592,12 +592,12 @@ struct CdmDecryptionParameters {
|
||||
: is_encrypted(true),
|
||||
is_secure(true),
|
||||
cipher_mode(kCipherModeCtr),
|
||||
key_id(NULL),
|
||||
encrypt_buffer(NULL),
|
||||
key_id(nullptr),
|
||||
encrypt_buffer(nullptr),
|
||||
encrypt_length(0),
|
||||
iv(NULL),
|
||||
iv(nullptr),
|
||||
block_offset(0),
|
||||
decrypt_buffer(NULL),
|
||||
decrypt_buffer(nullptr),
|
||||
decrypt_buffer_length(0),
|
||||
decrypt_buffer_offset(0),
|
||||
subsample_flags(0),
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace wvcdm {
|
||||
|
||||
bool BufferReader::Read1(uint8_t* v) {
|
||||
if (v == NULL) {
|
||||
if (v == nullptr) {
|
||||
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ bool BufferReader::Read1(uint8_t* v) {
|
||||
// Internal implementation of multi-byte reads
|
||||
template <typename T>
|
||||
bool BufferReader::Read(T* v) {
|
||||
if (v == NULL) {
|
||||
if (v == nullptr) {
|
||||
LOGE("Parse failure: Null output parameter when expecting non-null (%s)",
|
||||
__PRETTY_FUNCTION__);
|
||||
return false;
|
||||
@@ -55,7 +55,7 @@ bool BufferReader::Read8(uint64_t* v) { return Read(v); }
|
||||
bool BufferReader::Read8s(int64_t* v) { return Read(v); }
|
||||
|
||||
bool BufferReader::ReadString(std::string* str, size_t count) {
|
||||
if (str == NULL) {
|
||||
if (str == nullptr) {
|
||||
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ bool BufferReader::ReadString(std::string* str, size_t count) {
|
||||
}
|
||||
|
||||
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
|
||||
if (vec == NULL) {
|
||||
if (vec == nullptr) {
|
||||
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ bool BufferReader::SkipBytes(size_t bytes) {
|
||||
}
|
||||
|
||||
bool BufferReader::Read4Into8(uint64_t* v) {
|
||||
if (v == NULL) {
|
||||
if (v == nullptr) {
|
||||
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ bool BufferReader::Read4Into8(uint64_t* v) {
|
||||
}
|
||||
|
||||
bool BufferReader::Read4sInto8s(int64_t* v) {
|
||||
if (v == NULL) {
|
||||
if (v == nullptr) {
|
||||
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,14 +101,14 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
const CdmSessionId& forced_session_id,
|
||||
WvCdmEventListener* event_listener) {
|
||||
return OpenSession(key_system, property_set, event_listener,
|
||||
&forced_session_id, NULL);
|
||||
&forced_session_id, nullptr);
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||
CdmClientPropertySet* property_set,
|
||||
WvCdmEventListener* event_listener,
|
||||
CdmSessionId* session_id) {
|
||||
return OpenSession(key_system, property_set, event_listener, NULL,
|
||||
return OpenSession(key_system, property_set, event_listener, nullptr,
|
||||
session_id);
|
||||
}
|
||||
|
||||
@@ -182,8 +182,9 @@ CdmResponseType CdmEngine::OpenKeySetSession(
|
||||
if (key_set_in_use) CloseKeySetSession(key_set_id);
|
||||
|
||||
CdmSessionId session_id;
|
||||
CdmResponseType sts = OpenSession(KEY_SYSTEM, property_set, event_listener,
|
||||
NULL /* forced_session_id */, &session_id);
|
||||
CdmResponseType sts =
|
||||
OpenSession(KEY_SYSTEM, property_set, event_listener,
|
||||
nullptr /* forced_session_id */, &session_id);
|
||||
|
||||
if (sts != NO_ERROR) return sts;
|
||||
|
||||
@@ -882,7 +883,7 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
|
||||
DeleteAllUsageReportsUponFactoryReset();
|
||||
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
if (!cert_provisioning_) {
|
||||
cert_provisioning_.reset(
|
||||
new CertificateProvisioning(metrics_->GetCryptoMetrics()));
|
||||
CdmResponseType status = cert_provisioning_->Init(service_certificate);
|
||||
@@ -892,7 +893,7 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
cert_provisioning_requested_security_level_, cert_type, cert_authority,
|
||||
file_system_->origin(), spoid_, request, default_url);
|
||||
if (ret != NO_ERROR) {
|
||||
cert_provisioning_.reset(NULL); // Release resources.
|
||||
cert_provisioning_.reset(); // Release resources.
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -910,20 +911,20 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
LOGI("Handling provision request");
|
||||
if (response.empty()) {
|
||||
LOGE("Empty provisioning response");
|
||||
cert_provisioning_.reset(NULL);
|
||||
cert_provisioning_.reset();
|
||||
return EMPTY_PROVISIONING_RESPONSE;
|
||||
}
|
||||
if (cert == NULL) {
|
||||
if (cert == nullptr) {
|
||||
LOGE("Invalid certificate destination");
|
||||
cert_provisioning_.reset(NULL);
|
||||
cert_provisioning_.reset();
|
||||
return INVALID_PROVISIONING_PARAMETERS_1;
|
||||
}
|
||||
if (wrapped_key == NULL) {
|
||||
if (wrapped_key == nullptr) {
|
||||
LOGE("Invalid wrapped key destination");
|
||||
cert_provisioning_.reset(NULL);
|
||||
cert_provisioning_.reset();
|
||||
return INVALID_PROVISIONING_PARAMETERS_2;
|
||||
}
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
if (!cert_provisioning_) {
|
||||
// Certificate provisioning object has been released. Check if a concurrent
|
||||
// provisioning attempt has succeeded before declaring failure.
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
@@ -951,7 +952,7 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
// attempt was made after this one was requested but before the response was
|
||||
// received, which will cause this attempt to fail. Not releasing will
|
||||
// allow for the possibility that the later attempt succeeds.
|
||||
if (NO_ERROR == ret) cert_provisioning_.reset(NULL);
|
||||
if (NO_ERROR == ret) cert_provisioning_.reset();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1184,7 +1185,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("Getting usage info: app_id = %s, ssid = %s", app_id.c_str(),
|
||||
ssid.c_str());
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
if (!usage_info) {
|
||||
@@ -1289,7 +1290,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("Getting usage info: app_id = %s, security_level = %d", app_id.c_str(),
|
||||
static_cast<int>(requested_security_level));
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
usage_property_set_->set_security_level(requested_security_level);
|
||||
@@ -1362,7 +1363,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
||||
const std::string& app_id, CdmSecurityLevel cdm_security_level) {
|
||||
LOGI("Removing all usage info: app_id = %s, security_level = %d",
|
||||
app_id.c_str(), static_cast<int>(cdm_security_level));
|
||||
if (usage_property_set_.get() == nullptr) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
@@ -1436,7 +1437,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
||||
break;
|
||||
}
|
||||
}
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1453,7 +1454,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
const std::string& app_id, const CdmSecureStopId& provider_session_token) {
|
||||
LOGI("Removing usage info: app_id = %s, pst = %s", app_id.c_str(),
|
||||
provider_session_token.c_str());
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
if (!usage_property_set_) {
|
||||
usage_property_set_.reset(new UsagePropertySet());
|
||||
}
|
||||
usage_property_set_->set_app_id(app_id);
|
||||
@@ -1492,7 +1493,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
provider_session_token)) {
|
||||
status = REMOVE_USAGE_INFO_ERROR_1;
|
||||
}
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
return status;
|
||||
}
|
||||
case kUsageTableSupport: {
|
||||
@@ -1522,20 +1523,20 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
status = REMOVE_USAGE_INFO_ERROR_2;
|
||||
}
|
||||
}
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
return REMOVE_USAGE_INFO_ERROR_3;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::ReleaseUsageInfo(
|
||||
const CdmUsageInfoReleaseMessage& message) {
|
||||
LOGI("Releasing usage info");
|
||||
if (NULL == usage_session_.get()) {
|
||||
if (!usage_session_) {
|
||||
LOGE("CDM session not initialized");
|
||||
return RELEASE_USAGE_INFO_ERROR;
|
||||
}
|
||||
|
||||
CdmResponseType status = usage_session_->ReleaseKey(message);
|
||||
usage_session_.reset(NULL);
|
||||
usage_session_.reset();
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("ReleaseKey failed: status = %d", status);
|
||||
}
|
||||
@@ -1617,22 +1618,22 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
||||
|
||||
CdmResponseType CdmEngine::Decrypt(const CdmSessionId& session_id,
|
||||
const CdmDecryptionParameters& parameters) {
|
||||
if (parameters.key_id == NULL) {
|
||||
if (parameters.key_id == nullptr) {
|
||||
LOGE("No key ID");
|
||||
return INVALID_DECRYPT_PARAMETERS_ENG_1;
|
||||
}
|
||||
|
||||
if (parameters.encrypt_buffer == NULL) {
|
||||
if (parameters.encrypt_buffer == nullptr) {
|
||||
LOGE("No src encrypt buffer");
|
||||
return INVALID_DECRYPT_PARAMETERS_ENG_2;
|
||||
}
|
||||
|
||||
if (parameters.iv == NULL) {
|
||||
if (parameters.iv == nullptr) {
|
||||
LOGE("No IV");
|
||||
return INVALID_DECRYPT_PARAMETERS_ENG_3;
|
||||
}
|
||||
|
||||
if (parameters.decrypt_buffer == NULL) {
|
||||
if (parameters.decrypt_buffer == nullptr) {
|
||||
if (!parameters.is_secure &&
|
||||
!Properties::Properties::oem_crypto_use_fifo()) {
|
||||
LOGE("No dest decrypt buffer");
|
||||
@@ -1660,7 +1661,7 @@ CdmResponseType CdmEngine::Decrypt(const CdmSessionId& session_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (session.get() == NULL) {
|
||||
if (!session) {
|
||||
LOGE("Session not found: Empty session ID");
|
||||
return SESSION_NOT_FOUND_FOR_DECRYPT;
|
||||
}
|
||||
@@ -1680,7 +1681,7 @@ CdmResponseType CdmEngine::GenericEncrypt(const std::string& session_id,
|
||||
const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm,
|
||||
std::string* out_buffer) {
|
||||
if (out_buffer == NULL) {
|
||||
if (out_buffer == nullptr) {
|
||||
LOGE("No out buffer provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
@@ -1698,7 +1699,7 @@ CdmResponseType CdmEngine::GenericDecrypt(const std::string& session_id,
|
||||
const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm,
|
||||
std::string* out_buffer) {
|
||||
if (out_buffer == NULL) {
|
||||
if (out_buffer == nullptr) {
|
||||
LOGE("No out buffer provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
@@ -1715,7 +1716,7 @@ CdmResponseType CdmEngine::GenericSign(const std::string& session_id,
|
||||
const std::string& key_id,
|
||||
CdmSigningAlgorithm algorithm,
|
||||
std::string* signature) {
|
||||
if (signature == NULL) {
|
||||
if (signature == nullptr) {
|
||||
LOGE("No signature buffer provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
@@ -1833,7 +1834,7 @@ bool CdmEngine::IsKeyLoaded(const KeyId& key_id) {
|
||||
|
||||
bool CdmEngine::FindSessionForKey(const KeyId& key_id,
|
||||
CdmSessionId* session_id) {
|
||||
if (NULL == session_id) {
|
||||
if (session_id == nullptr) {
|
||||
LOGE("No session ID destination provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ CdmSession::CdmSession(FileSystem* file_system,
|
||||
is_initial_usage_update_(true),
|
||||
is_usage_update_needed_(false),
|
||||
usage_support_type_(kNonSecureUsageSupport),
|
||||
usage_table_header_(NULL),
|
||||
usage_table_header_(nullptr),
|
||||
usage_entry_number_(0),
|
||||
mock_license_parser_in_use_(false),
|
||||
mock_policy_engine_in_use_(false) {
|
||||
assert(metrics_.get()); // metrics_ must not be null.
|
||||
assert(metrics_); // metrics_ must not be null.
|
||||
crypto_metrics_ = metrics_->GetCryptoMetrics();
|
||||
crypto_session_.reset(CryptoSession::MakeCryptoSession(crypto_metrics_));
|
||||
life_span_.Start();
|
||||
@@ -63,7 +63,7 @@ CdmSession::CdmSession(FileSystem* file_system,
|
||||
|
||||
CdmSession::~CdmSession() {
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
has_provider_session_token() && usage_table_header_ != NULL &&
|
||||
has_provider_session_token() && usage_table_header_ != nullptr &&
|
||||
!is_release_) {
|
||||
UpdateUsageEntryInformation();
|
||||
}
|
||||
@@ -74,7 +74,7 @@ CdmSession::~CdmSession() {
|
||||
}
|
||||
Properties::RemoveSessionPropertySet(session_id_);
|
||||
|
||||
if (metrics_.get()) {
|
||||
if (metrics_) {
|
||||
M_RECORD(metrics_.get(), cdm_session_life_span_, life_span_.AsMs());
|
||||
metrics_->SetCompleted();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ CdmSession::~CdmSession() {
|
||||
|
||||
CdmResponseType CdmSession::Init(
|
||||
CdmClientPropertySet* cdm_client_property_set) {
|
||||
return Init(cdm_client_property_set, NULL, NULL);
|
||||
return Init(cdm_client_property_set, nullptr, nullptr);
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
@@ -142,7 +142,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
// indicate that provisioning is needed. Get token from stored certificate
|
||||
std::string wrapped_key;
|
||||
if (!file_handle_->RetrieveCertificate(&client_token, &wrapped_key,
|
||||
&serial_number, NULL)) {
|
||||
&serial_number, nullptr)) {
|
||||
return NEED_PROVISIONING;
|
||||
}
|
||||
CdmResponseType load_cert_sts;
|
||||
@@ -260,7 +260,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
||||
if (usage_support_type_ == kUsageEntrySupport) {
|
||||
if (!license_parser_->ExtractProviderSessionToken(
|
||||
key_response_, &provider_session_token) ||
|
||||
usage_table_header_ == NULL) {
|
||||
usage_table_header_ == nullptr) {
|
||||
provider_session_token.clear();
|
||||
} else {
|
||||
CdmResponseType sts = usage_table_header_->LoadEntry(
|
||||
@@ -293,7 +293,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
||||
}
|
||||
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
!provider_session_token.empty() && usage_table_header_ != NULL) {
|
||||
!provider_session_token.empty() && usage_table_header_ != nullptr) {
|
||||
CdmResponseType sts =
|
||||
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
||||
if (sts != NO_ERROR) {
|
||||
@@ -329,7 +329,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
||||
|
||||
CdmResponseType sts = NO_ERROR;
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
usage_table_header_ != NULL) {
|
||||
usage_table_header_ != nullptr) {
|
||||
sts = usage_table_header_->LoadEntry(crypto_session_.get(), usage_entry_,
|
||||
usage_entry_number_);
|
||||
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
||||
@@ -347,7 +347,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
||||
}
|
||||
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
usage_table_header_ != NULL) {
|
||||
usage_table_header_ != nullptr) {
|
||||
sts =
|
||||
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
||||
if (sts != NO_ERROR) {
|
||||
@@ -490,7 +490,7 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
||||
CdmResponseType sts;
|
||||
std::string provider_session_token;
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
usage_table_header_ != NULL) {
|
||||
usage_table_header_ != nullptr) {
|
||||
if (license_parser_->ExtractProviderSessionToken(
|
||||
key_response, &provider_session_token) &&
|
||||
!provider_session_token.empty()) {
|
||||
@@ -513,7 +513,7 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
||||
|
||||
// Update or delete entry if usage table header+entries are supported
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
!provider_session_token.empty() && usage_table_header_ != NULL) {
|
||||
!provider_session_token.empty() && usage_table_header_ != nullptr) {
|
||||
if (sts != KEY_ADDED) {
|
||||
CdmResponseType delete_sts = usage_table_header_->DeleteEntry(
|
||||
usage_entry_number_, file_handle_.get(), crypto_metrics_);
|
||||
@@ -537,7 +537,7 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
||||
if (is_offline_ || has_provider_session_token()) {
|
||||
if (has_provider_session_token() &&
|
||||
usage_support_type_ == kUsageEntrySupport &&
|
||||
usage_table_header_ != NULL) {
|
||||
usage_table_header_ != nullptr) {
|
||||
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
|
||||
return NOT_INITIALIZED_ERROR;
|
||||
}
|
||||
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
|
||||
true, app_parameters_, NULL, &key_request->message, &key_request->url);
|
||||
true, app_parameters_, nullptr, &key_request->message, &key_request->url);
|
||||
|
||||
key_request->type = kKeyRequestTypeRenewal;
|
||||
|
||||
@@ -701,7 +701,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
||||
is_release_ = true;
|
||||
license_request_latency_.Clear();
|
||||
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
|
||||
false, app_parameters_, usage_table_header_ == NULL ? NULL : this,
|
||||
false, app_parameters_, usage_table_header_ == nullptr ? nullptr : this,
|
||||
&key_request->message, &key_request->url);
|
||||
|
||||
key_request->type = kKeyRequestTypeRelease;
|
||||
@@ -771,7 +771,7 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||
crypto_metrics_, crypto_session_open_, sts, requested_security_level_);
|
||||
if (sts != NO_ERROR) return sts;
|
||||
|
||||
usage_table_header_ = NULL;
|
||||
usage_table_header_ = nullptr;
|
||||
if (crypto_session_->GetUsageSupportType(&usage_support_type_) == NO_ERROR) {
|
||||
if (usage_support_type_ == kUsageEntrySupport)
|
||||
usage_table_header_ = crypto_session_->GetUsageTableHeader();
|
||||
@@ -779,7 +779,7 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||
usage_support_type_ = kNonSecureUsageSupport;
|
||||
}
|
||||
|
||||
if (usage_table_header_ == NULL) {
|
||||
if (usage_table_header_ == nullptr) {
|
||||
LOGE("Usage table header unavailable");
|
||||
return INCORRECT_USAGE_SUPPORT_TYPE_1;
|
||||
}
|
||||
@@ -915,7 +915,7 @@ CdmResponseType CdmSession::RemoveKeys() {
|
||||
M_TIME(sts = crypto_session_->Open(requested_security_level_),
|
||||
crypto_metrics_, crypto_session_open_, sts, requested_security_level_);
|
||||
policy_engine_.reset(
|
||||
new PolicyEngine(session_id_, NULL, crypto_session_.get()));
|
||||
new PolicyEngine(session_id_, nullptr, crypto_session_.get()));
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -1009,13 +1009,13 @@ CdmResponseType CdmSession::UpdateUsageTableInformation() {
|
||||
|
||||
CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
||||
if (usage_support_type_ != kUsageEntrySupport ||
|
||||
!has_provider_session_token() || usage_table_header_ == NULL) {
|
||||
!has_provider_session_token() || usage_table_header_ == nullptr) {
|
||||
LOGE(
|
||||
"Unexpected state: usage support type = %d, PST present = %s, "
|
||||
"usage table header available = %s",
|
||||
static_cast<int>(usage_support_type_),
|
||||
has_provider_session_token() ? "yes" : "no",
|
||||
usage_table_header_ == NULL ? "no" : "yes");
|
||||
usage_table_header_ == nullptr ? "no" : "yes");
|
||||
return INCORRECT_USAGE_SUPPORT_TYPE_2;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ bool CdmSessionMap::FindSessionNoLock(const CdmSessionId& session_id,
|
||||
return false;
|
||||
}
|
||||
*session = iter->second;
|
||||
assert(session->get() != NULL);
|
||||
assert(*session);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,9 +164,9 @@ OEMCryptoResult ContentKeySession::LoadKeysAsLicenseType(
|
||||
|
||||
LOGV("session_id = %u", oec_session_id_);
|
||||
OEMCryptoResult sts;
|
||||
OEMCrypto_KeyObject* key_array_ptr = NULL;
|
||||
OEMCrypto_KeyObject* key_array_ptr = nullptr;
|
||||
if (keys.size() > 0) key_array_ptr = &load_keys[0];
|
||||
OEMCryptoCipherMode* cipher_mode_ptr = NULL;
|
||||
OEMCryptoCipherMode* cipher_mode_ptr = nullptr;
|
||||
if (keys.size() > 0) cipher_mode_ptr = &cipher_modes[0];
|
||||
M_TIME(sts = ::OEMCrypto_LoadKeys_Back_Compat(
|
||||
oec_session_id_, msg, message.length(),
|
||||
|
||||
@@ -68,8 +68,8 @@ shared_mutex CryptoSession::static_field_mutex_;
|
||||
shared_mutex CryptoSession::oem_crypto_mutex_;
|
||||
bool CryptoSession::initialized_ = false;
|
||||
int CryptoSession::session_count_ = 0;
|
||||
UsageTableHeader* CryptoSession::usage_table_header_l1_ = NULL;
|
||||
UsageTableHeader* CryptoSession::usage_table_header_l3_ = NULL;
|
||||
UsageTableHeader* CryptoSession::usage_table_header_l1_ = nullptr;
|
||||
UsageTableHeader* CryptoSession::usage_table_header_l3_ = nullptr;
|
||||
std::atomic<uint64_t> CryptoSession::request_id_index_source_(0);
|
||||
|
||||
size_t GetOffset(std::string message, std::string field) {
|
||||
@@ -184,7 +184,7 @@ CryptoSession::CryptoSession(metrics::CryptoMetrics* metrics)
|
||||
requested_security_level_(kLevelDefault),
|
||||
is_usage_support_type_valid_(false),
|
||||
usage_support_type_(kUnknownUsageSupport),
|
||||
usage_table_header_(NULL),
|
||||
usage_table_header_(nullptr),
|
||||
cipher_mode_(kCipherModeCtr),
|
||||
api_version_(0) {
|
||||
assert(metrics);
|
||||
@@ -272,13 +272,13 @@ void CryptoSession::Terminate() {
|
||||
LOGE("OEMCrypto_Terminate failed: status = %d", static_cast<int>(sts));
|
||||
}
|
||||
|
||||
if (usage_table_header_l1_ != NULL) {
|
||||
if (usage_table_header_l1_ != nullptr) {
|
||||
delete usage_table_header_l1_;
|
||||
usage_table_header_l1_ = NULL;
|
||||
usage_table_header_l1_ = nullptr;
|
||||
}
|
||||
if (usage_table_header_l3_ != NULL) {
|
||||
if (usage_table_header_l3_ != nullptr) {
|
||||
delete usage_table_header_l3_;
|
||||
usage_table_header_l3_ = NULL;
|
||||
usage_table_header_l3_ = nullptr;
|
||||
}
|
||||
|
||||
initialized_ = false;
|
||||
@@ -472,7 +472,7 @@ CdmResponseType CryptoSession::GetExternalDeviceUniqueId(
|
||||
size_t id_length = 0;
|
||||
OEMCryptoResult sts;
|
||||
WithOecReadLock("GetExternalDeviceUniqueId", [&] {
|
||||
sts = OEMCrypto_GetDeviceID(NULL, &id_length, requested_security_level_);
|
||||
sts = OEMCrypto_GetDeviceID(nullptr, &id_length, requested_security_level_);
|
||||
});
|
||||
metrics_->oemcrypto_get_device_id_.Increment(sts);
|
||||
|
||||
@@ -710,7 +710,7 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
||||
UsageTableHeader** header = security_level == kSecurityLevelL1
|
||||
? &usage_table_header_l1_
|
||||
: &usage_table_header_l3_;
|
||||
if (*header == NULL) {
|
||||
if (*header == nullptr) {
|
||||
*header = new UsageTableHeader();
|
||||
// Ignore errors since we do not know when a session is opened,
|
||||
// if it is intended to be used for offline/usage session related
|
||||
@@ -721,8 +721,8 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
||||
auto_lock.lock();
|
||||
if (!is_usage_table_header_inited) {
|
||||
delete *header;
|
||||
*header = NULL;
|
||||
usage_table_header_ = NULL;
|
||||
*header = nullptr;
|
||||
usage_table_header_ = nullptr;
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -1279,7 +1279,7 @@ CdmResponseType CryptoSession::GenerateUsageReport(
|
||||
OEMCryptoResult status;
|
||||
WithOecWriteLock("GenerateUsageReport Attempt 1", [&] {
|
||||
status = OEMCrypto_ReportUsage(oec_session_id_, pst,
|
||||
provider_session_token.length(), NULL,
|
||||
provider_session_token.length(), nullptr,
|
||||
&usage_length);
|
||||
});
|
||||
metrics_->oemcrypto_report_usage_.Increment(status);
|
||||
@@ -1514,9 +1514,9 @@ CdmResponseType CryptoSession::RewrapDeviceRSAKey(
|
||||
LOGV("Rewrapping device RSA key: id = %u", oec_session_id_);
|
||||
|
||||
const uint8_t* signed_msg = reinterpret_cast<const uint8_t*>(message.data());
|
||||
const uint8_t* msg_rsa_key = NULL;
|
||||
const uint8_t* msg_rsa_key_iv = NULL;
|
||||
const uint32_t* msg_nonce = NULL;
|
||||
const uint8_t* msg_rsa_key = nullptr;
|
||||
const uint8_t* msg_rsa_key_iv = nullptr;
|
||||
const uint32_t* msg_nonce = nullptr;
|
||||
if (enc_rsa_key.size() >= MAC_KEY_SIZE && rsa_key_iv.size() >= KEY_IV_SIZE) {
|
||||
msg_rsa_key = signed_msg + GetOffset(message, enc_rsa_key);
|
||||
msg_rsa_key_iv = signed_msg + GetOffset(message, rsa_key_iv);
|
||||
@@ -1524,7 +1524,7 @@ CdmResponseType CryptoSession::RewrapDeviceRSAKey(
|
||||
GetOffset(message, nonce));
|
||||
}
|
||||
|
||||
// Gets wrapped_rsa_key_length by passing NULL as uint8_t* wrapped_rsa_key
|
||||
// Gets wrapped_rsa_key_length by passing nullptr as uint8_t* wrapped_rsa_key
|
||||
// and 0 as wrapped_rsa_key_length.
|
||||
size_t wrapped_rsa_key_length = 0;
|
||||
OEMCryptoResult status;
|
||||
@@ -1533,7 +1533,7 @@ CdmResponseType CryptoSession::RewrapDeviceRSAKey(
|
||||
oec_session_id_, signed_msg, message.size(),
|
||||
reinterpret_cast<const uint8_t*>(signature.data()),
|
||||
signature.size(), msg_nonce, msg_rsa_key, enc_rsa_key.size(),
|
||||
msg_rsa_key_iv, NULL, &wrapped_rsa_key_length),
|
||||
msg_rsa_key_iv, nullptr, &wrapped_rsa_key_length),
|
||||
metrics_, oemcrypto_rewrap_device_rsa_key_, status);
|
||||
});
|
||||
|
||||
@@ -1567,10 +1567,10 @@ CdmResponseType CryptoSession::RewrapDeviceRSAKey30(
|
||||
LOGV("Rewrapping Device RSA key 30: id = %u", oec_session_id_);
|
||||
|
||||
const uint8_t* signed_msg = reinterpret_cast<const uint8_t*>(message.data());
|
||||
const uint8_t* msg_private_key = NULL;
|
||||
const uint8_t* msg_iv = NULL;
|
||||
const uint32_t* msg_nonce = NULL;
|
||||
const uint8_t* msg_wrapping_key = NULL;
|
||||
const uint8_t* msg_private_key = nullptr;
|
||||
const uint8_t* msg_iv = nullptr;
|
||||
const uint32_t* msg_nonce = nullptr;
|
||||
const uint8_t* msg_wrapping_key = nullptr;
|
||||
if (private_key.size() >= MAC_KEY_SIZE && iv.size() >= KEY_IV_SIZE) {
|
||||
msg_private_key = signed_msg + GetOffset(message, private_key);
|
||||
msg_iv = signed_msg + GetOffset(message, iv);
|
||||
@@ -1579,7 +1579,7 @@ CdmResponseType CryptoSession::RewrapDeviceRSAKey30(
|
||||
msg_wrapping_key = signed_msg + GetOffset(message, wrapping_key);
|
||||
}
|
||||
|
||||
// Gets wrapped_rsa_key_length by passing NULL as uint8_t* wrapped_rsa_key
|
||||
// Gets wrapped_rsa_key_length by passing nullptr as uint8_t* wrapped_rsa_key
|
||||
// and 0 as wrapped_rsa_key_length.
|
||||
size_t wrapped_private_key_length = 0;
|
||||
OEMCryptoResult status;
|
||||
@@ -1587,7 +1587,7 @@ CdmResponseType CryptoSession::RewrapDeviceRSAKey30(
|
||||
M_TIME(status = OEMCrypto_RewrapDeviceRSAKey30(
|
||||
oec_session_id_, msg_nonce, msg_wrapping_key,
|
||||
wrapping_key.size(), msg_private_key, private_key.size(), msg_iv,
|
||||
NULL, &wrapped_private_key_length),
|
||||
nullptr, &wrapped_private_key_length),
|
||||
metrics_, oemcrypto_rewrap_device_rsa_key_30_, status);
|
||||
});
|
||||
|
||||
@@ -2374,8 +2374,9 @@ CdmResponseType CryptoSession::UpdateUsageEntry(
|
||||
size_t usage_entry_len = 0;
|
||||
OEMCryptoResult result;
|
||||
WithOecWriteLock("UpdateUsageEntry Attempt 1", [&] {
|
||||
result = OEMCrypto_UpdateUsageEntry(
|
||||
oec_session_id_, NULL, &usage_table_header_len, NULL, &usage_entry_len);
|
||||
result = OEMCrypto_UpdateUsageEntry(oec_session_id_, nullptr,
|
||||
&usage_table_header_len, nullptr,
|
||||
&usage_entry_len);
|
||||
});
|
||||
metrics_->oemcrypto_update_usage_entry_.Increment(result);
|
||||
|
||||
@@ -2417,7 +2418,7 @@ CdmResponseType CryptoSession::ShrinkUsageTableHeader(
|
||||
OEMCryptoResult result;
|
||||
WithOecWriteLock("ShrinkUsageTableHeader Attempt 1", [&] {
|
||||
result = OEMCrypto_ShrinkUsageTableHeader(requested_security_level_,
|
||||
new_entry_count, NULL,
|
||||
new_entry_count, nullptr,
|
||||
&usage_table_header_len);
|
||||
metrics_->oemcrypto_shrink_usage_table_header_.Increment(result);
|
||||
});
|
||||
@@ -2726,7 +2727,7 @@ OEMCryptoResult CryptoSession::DecryptInChunks(
|
||||
const uint8_t* const buffer_end =
|
||||
params.encrypt_buffer + additional_offset + chunk_size;
|
||||
|
||||
const uint8_t* block_end = NULL;
|
||||
const uint8_t* block_end = nullptr;
|
||||
if (pattern_length_in_bytes == 0) {
|
||||
// For cbc1, the last encrypted block is the last block of the
|
||||
// subsample.
|
||||
@@ -2814,7 +2815,7 @@ CryptoSession* CryptoSession::MakeCryptoSession(
|
||||
metrics::CryptoMetrics* crypto_metrics) {
|
||||
std::unique_lock<std::mutex> auto_lock(factory_mutex_);
|
||||
// If the factory_ has not been set, then use a default factory.
|
||||
if (factory_.get() == NULL) factory_.reset(new CryptoSessionFactory());
|
||||
if (!factory_) factory_.reset(new CryptoSessionFactory());
|
||||
return factory_->MakeCryptoSession(crypto_metrics);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,10 +192,10 @@ bool DeviceFiles::ExtractDeviceInfo(const std::string& device_certificate,
|
||||
LOGE("Failed to parse DRM device certificate message");
|
||||
return false;
|
||||
}
|
||||
if (serial_number != NULL) {
|
||||
if (serial_number != nullptr) {
|
||||
*serial_number = drm_device_certificate.serial_number();
|
||||
}
|
||||
if (system_id != NULL) {
|
||||
if (system_id != nullptr) {
|
||||
*system_id = drm_device_certificate.system_id();
|
||||
}
|
||||
return true;
|
||||
@@ -283,7 +283,7 @@ bool DeviceFiles::RetrieveLicense(
|
||||
CdmAppParameterMap* app_parameters, CdmUsageEntry* usage_entry,
|
||||
uint32_t* usage_entry_number, ResponseType* result) {
|
||||
// This check must be made first as the RETURN_FALSE_IF_NULL() macro
|
||||
// will assign NULL_PARAMETER to |result|.
|
||||
// will assign kParameterNull to |result|.
|
||||
if (result == nullptr) {
|
||||
LOGE("Output parameter |result| not provided");
|
||||
return false;
|
||||
|
||||
@@ -205,7 +205,7 @@ bool CdmLicense::Init(const std::string& client_token,
|
||||
const std::string& device_id, bool use_privacy_mode,
|
||||
const std::string& signed_service_certificate,
|
||||
CryptoSession* session, PolicyEngine* policy_engine) {
|
||||
if (clock_.get() == nullptr) {
|
||||
if (!clock_) {
|
||||
LOGE("Clock parameter not provided");
|
||||
return false;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_4;
|
||||
}
|
||||
if (init_data.IsEmpty() && stored_init_data_.get()) {
|
||||
if (init_data.IsEmpty() && stored_init_data_) {
|
||||
InitializationData restored_init_data = *stored_init_data_;
|
||||
stored_init_data_.reset();
|
||||
return PrepareKeyRequest(restored_init_data, license_type, app_parameters,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -62,6 +62,7 @@ class boringssl_ptr {
|
||||
T& operator*() const { return *ptr_; }
|
||||
T* operator->() const { return ptr_; }
|
||||
T* get() const { return ptr_; }
|
||||
explicit operator bool() const { return ptr_ != nullptr; }
|
||||
|
||||
private:
|
||||
T* ptr_;
|
||||
@@ -328,7 +329,7 @@ bool ExtractExtensionValueFromCertificate(const std::string& cert,
|
||||
// Load the certificate chain into a BoringSSL X509 Stack
|
||||
const boringssl_ptr<STACK_OF(X509), DeleteX509Stack> x509_stack(
|
||||
sk_X509_new_null());
|
||||
if (x509_stack.get() == nullptr) {
|
||||
if (!x509_stack) {
|
||||
LOGE("Unable to allocate X509 stack");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ std::unique_ptr<CdmClientPropertySetMap> Properties::session_property_set_;
|
||||
|
||||
bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
||||
CdmClientPropertySet* property_set) {
|
||||
if (NULL == session_property_set_.get()) {
|
||||
if (!session_property_set_) {
|
||||
return false;
|
||||
}
|
||||
std::pair<CdmClientPropertySetMap::iterator, bool> result =
|
||||
@@ -36,7 +36,7 @@ bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
||||
}
|
||||
|
||||
bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
||||
if (NULL == session_property_set_.get()) {
|
||||
if (!session_property_set_) {
|
||||
return false;
|
||||
}
|
||||
return (1 == session_property_set_->erase(session_id));
|
||||
@@ -44,21 +44,21 @@ bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
||||
|
||||
CdmClientPropertySet* Properties::GetCdmClientPropertySet(
|
||||
const CdmSessionId& session_id) {
|
||||
if (NULL != session_property_set_.get()) {
|
||||
if (session_property_set_) {
|
||||
CdmClientPropertySetMap::iterator it =
|
||||
session_property_set_->find(session_id);
|
||||
if (it != session_property_set_->end()) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Properties::GetApplicationId(const CdmSessionId& session_id,
|
||||
std::string* app_id) {
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
if (property_set == nullptr) {
|
||||
return false;
|
||||
}
|
||||
*app_id = property_set->app_id();
|
||||
@@ -69,7 +69,7 @@ bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
||||
std::string* service_certificate) {
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (property_set == NULL) {
|
||||
if (property_set == nullptr) {
|
||||
return false;
|
||||
}
|
||||
*service_certificate = property_set->service_certificate();
|
||||
@@ -79,7 +79,7 @@ bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
||||
bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
||||
const std::string& service_certificate) {
|
||||
CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id);
|
||||
if (property_set == NULL) {
|
||||
if (property_set == nullptr) {
|
||||
return false;
|
||||
}
|
||||
property_set->set_service_certificate(service_certificate);
|
||||
@@ -89,7 +89,7 @@ bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
||||
bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
if (property_set == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return property_set->use_privacy_mode();
|
||||
@@ -98,7 +98,7 @@ bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
||||
uint32_t Properties::GetSessionSharingId(const CdmSessionId& session_id) {
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
if (property_set == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return property_set->session_sharing_id();
|
||||
|
||||
@@ -203,7 +203,7 @@ CdmResponseType ServiceCertificate::Init(const std::string& certificate) {
|
||||
|
||||
CdmResponseType ServiceCertificate::VerifySignedMessage(
|
||||
const std::string& message, const std::string& signature) {
|
||||
if (public_key_.get() == nullptr) {
|
||||
if (!public_key_) {
|
||||
LOGE("Service certificate not set");
|
||||
return DEVICE_CERTIFICATE_ERROR_4;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ CdmResponseType ServiceCertificate::VerifySignedMessage(
|
||||
|
||||
CdmResponseType ServiceCertificate::EncryptRsaOaep(const std::string& plaintext,
|
||||
std::string* ciphertext) {
|
||||
if (public_key_.get() == nullptr) {
|
||||
if (!public_key_) {
|
||||
LOGE("Service certificate not set");
|
||||
return DEVICE_CERTIFICATE_ERROR_4;
|
||||
}
|
||||
|
||||
@@ -176,16 +176,16 @@ TEST_F(BufferReaderTest, InitializeGoodDataAndNoSize) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, InitializeNoDataNoSize) {
|
||||
BufferReader reader(NULL, 0);
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
BufferReader reader(nullptr, 0);
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, InitializeNoDataBadSize) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
// Buffer reader should default to a size of 0 when given
|
||||
// NULL data to ensure no reading of bad data
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, HasBytesWithBytes) {
|
||||
@@ -219,12 +219,12 @@ TEST_F(BufferReaderTest, HasBytesWithEmptyBuffer) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, HasBytesWithNullBuffer) {
|
||||
BufferReader reader(NULL, 8);
|
||||
BufferReader reader(nullptr, 8);
|
||||
|
||||
ASSERT_FALSE(reader.HasBytes(1));
|
||||
ASSERT_TRUE(reader.HasBytes(0));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, HasBytesAfterAllRead) {
|
||||
@@ -266,12 +266,12 @@ TEST_F(BufferReaderTest, Read1WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read1WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint8_t read;
|
||||
ASSERT_FALSE(reader.Read1(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read1WithNullReturn) {
|
||||
@@ -280,7 +280,7 @@ TEST_F(BufferReaderTest, Read1WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read1(NULL));
|
||||
ASSERT_FALSE(reader.Read1(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -306,12 +306,12 @@ TEST_F(BufferReaderTest, Read2WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint16_t read;
|
||||
ASSERT_FALSE(reader.Read2(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2WithNullReturn) {
|
||||
@@ -320,7 +320,7 @@ TEST_F(BufferReaderTest, Read2WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read2(NULL));
|
||||
ASSERT_FALSE(reader.Read2(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -354,12 +354,12 @@ TEST_F(BufferReaderTest, Read2sWithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2sWithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
int16_t read;
|
||||
ASSERT_FALSE(reader.Read2s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read2sWithNullReturn) {
|
||||
@@ -368,7 +368,7 @@ TEST_F(BufferReaderTest, Read2sWithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read2s(NULL));
|
||||
ASSERT_FALSE(reader.Read2s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -397,12 +397,12 @@ TEST_F(BufferReaderTest, Read4WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint32_t read;
|
||||
ASSERT_FALSE(reader.Read4(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4WithNullReturn) {
|
||||
@@ -411,7 +411,7 @@ TEST_F(BufferReaderTest, Read4WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4(NULL));
|
||||
ASSERT_FALSE(reader.Read4(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -447,12 +447,12 @@ TEST_F(BufferReaderTest, Read4sWithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sWithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
int32_t read;
|
||||
ASSERT_FALSE(reader.Read4s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sWithNullReturn) {
|
||||
@@ -461,7 +461,7 @@ TEST_F(BufferReaderTest, Read4sWithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4s(NULL));
|
||||
ASSERT_FALSE(reader.Read4s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -490,12 +490,12 @@ TEST_F(BufferReaderTest, Read8WithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8WithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
uint64_t read;
|
||||
ASSERT_FALSE(reader.Read8(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8WithNullReturn) {
|
||||
@@ -504,7 +504,7 @@ TEST_F(BufferReaderTest, Read8WithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read8(NULL));
|
||||
ASSERT_FALSE(reader.Read8(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -540,12 +540,12 @@ TEST_F(BufferReaderTest, Read8sWithNoData) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8sWithNullBuffer) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
int64_t read;
|
||||
ASSERT_FALSE(reader.Read8s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read8sWithNullReturn) {
|
||||
@@ -554,7 +554,7 @@ TEST_F(BufferReaderTest, Read8sWithNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read8s(NULL));
|
||||
ASSERT_FALSE(reader.Read8s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -578,12 +578,12 @@ TEST_F(BufferReaderTest, ReadString) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadStringNullSource) {
|
||||
BufferReader reader(NULL, 5);
|
||||
BufferReader reader(nullptr, 5);
|
||||
|
||||
std::string read;
|
||||
ASSERT_FALSE(reader.ReadString(&read, 5));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadStringNullReturn) {
|
||||
@@ -592,7 +592,7 @@ TEST_F(BufferReaderTest, ReadStringNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.ReadString(NULL, 5));
|
||||
ASSERT_FALSE(reader.ReadString(nullptr, 5));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -662,13 +662,13 @@ TEST_F(BufferReaderTest, ReadVectorTooLarge) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadVectorNullSource) {
|
||||
BufferReader reader(NULL, 16);
|
||||
BufferReader reader(nullptr, 16);
|
||||
|
||||
std::vector<uint8_t> read;
|
||||
ASSERT_FALSE(reader.ReadVec(&read, 4));
|
||||
|
||||
ASSERT_TRUE(0 == read.size());
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, ReadVectorNullReturn) {
|
||||
@@ -677,7 +677,7 @@ TEST_F(BufferReaderTest, ReadVectorNullReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.ReadVec(NULL, 4));
|
||||
ASSERT_FALSE(reader.ReadVec(nullptr, 4));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -712,12 +712,12 @@ TEST_F(BufferReaderTest, Read4Into82Bytes) {
|
||||
TEST_F(BufferReaderTest, Read4Into8Zero) { ASSERT_TRUE(CheckRead4Into8(0)); }
|
||||
|
||||
TEST_F(BufferReaderTest, Read4Into8NullSource) {
|
||||
BufferReader reader(NULL, 4);
|
||||
BufferReader reader(nullptr, 4);
|
||||
|
||||
uint64_t read;
|
||||
ASSERT_FALSE(reader.Read4Into8(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4Into8TooLittleData) {
|
||||
@@ -739,7 +739,7 @@ TEST_F(BufferReaderTest, Read4Into8NoReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4Into8(NULL));
|
||||
ASSERT_FALSE(reader.Read4Into8(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
@@ -770,12 +770,12 @@ TEST_F(BufferReaderTest, Read4sInto8sNegative) {
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sInto8sNullSource) {
|
||||
BufferReader reader(NULL, 4);
|
||||
BufferReader reader(nullptr, 4);
|
||||
|
||||
int64_t read;
|
||||
ASSERT_FALSE(reader.Read4sInto8s(&read));
|
||||
|
||||
ASSERT_TRUE(ValidateReader(reader, NULL, 0, 0));
|
||||
ASSERT_TRUE(ValidateReader(reader, nullptr, 0, 0));
|
||||
}
|
||||
|
||||
TEST_F(BufferReaderTest, Read4sInto8sTooLittleData) {
|
||||
@@ -797,7 +797,7 @@ TEST_F(BufferReaderTest, Read4sInto8sNoReturn) {
|
||||
|
||||
BufferReader reader(raw_data, sizeof(raw_data));
|
||||
|
||||
ASSERT_FALSE(reader.Read4sInto8s(NULL));
|
||||
ASSERT_FALSE(reader.Read4sInto8s(nullptr));
|
||||
|
||||
ASSERT_TRUE(ValidateData(raw_data, sizeof(raw_data)));
|
||||
ASSERT_TRUE(ValidateReader(reader, raw_data, sizeof(raw_data), 0));
|
||||
|
||||
@@ -61,11 +61,11 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
virtual void OpenSession() {
|
||||
CdmResponseType status =
|
||||
cdm_engine_.OpenSession(config_.key_system(), NULL, NULL, &session_id_);
|
||||
CdmResponseType status = cdm_engine_.OpenSession(
|
||||
config_.key_system(), nullptr, nullptr, &session_id_);
|
||||
if (status == NEED_PROVISIONING) {
|
||||
Provision();
|
||||
status = cdm_engine_.OpenSession(config_.key_system(), NULL, NULL,
|
||||
status = cdm_engine_.OpenSession(config_.key_system(), nullptr, nullptr,
|
||||
&session_id_);
|
||||
}
|
||||
ASSERT_EQ(status, NO_ERROR);
|
||||
|
||||
@@ -111,7 +111,7 @@ const std::string kWrappedKey = a2bs_hex(
|
||||
|
||||
class MockDeviceFiles : public DeviceFiles {
|
||||
public:
|
||||
MockDeviceFiles() : DeviceFiles(NULL) {}
|
||||
MockDeviceFiles() : DeviceFiles(nullptr) {}
|
||||
|
||||
MOCK_METHOD1(Init, bool(CdmSecurityLevel));
|
||||
MOCK_METHOD4(RetrieveCertificate, bool(std::string*, std::string*,
|
||||
@@ -154,7 +154,7 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
class MockPolicyEngine : public PolicyEngine {
|
||||
public:
|
||||
MockPolicyEngine(CryptoSession* crypto_session)
|
||||
: PolicyEngine("mock_session_id", NULL, crypto_session) {}
|
||||
: PolicyEngine("mock_session_id", nullptr, crypto_session) {}
|
||||
|
||||
// Leaving a place-holder for when PolicyEngine methods need to be mocked
|
||||
};
|
||||
@@ -177,7 +177,7 @@ class CdmSessionTest : public WvCdmTestBase {
|
||||
void SetUp() override {
|
||||
WvCdmTestBase::SetUp();
|
||||
metrics_.reset(new metrics::SessionMetrics);
|
||||
cdm_session_.reset(new CdmSession(NULL, metrics_));
|
||||
cdm_session_.reset(new CdmSession(nullptr, metrics_));
|
||||
// Inject testing mocks.
|
||||
license_parser_ = new MockCdmLicense(cdm_session_->session_id());
|
||||
cdm_session_->set_license_parser(license_parser_);
|
||||
@@ -230,7 +230,7 @@ TEST_F(CdmSessionTest, InitWithBuiltInCertificate) {
|
||||
Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
@@ -258,7 +258,7 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, ReInitFail) {
|
||||
@@ -285,15 +285,15 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
||||
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_NE(NO_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
ASSERT_NE(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitFailCryptoError) {
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.WillOnce(Return(UNKNOWN_ERROR));
|
||||
|
||||
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||
@@ -312,7 +312,7 @@ TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||
NotNull(), _))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init(NULL));
|
||||
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
||||
@@ -352,7 +352,7 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
||||
EXPECT_CALL(usage_table_header_, UpdateEntry(NotNull(), NotNull()))
|
||||
.WillRepeatedly(Return(NO_ERROR));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
EXPECT_EQ(kUsageEntrySupport, cdm_session_->get_usage_support_type())
|
||||
<< "Usage support type: " << cdm_session_->get_usage_support_type();
|
||||
EXPECT_EQ(NO_ERROR, cdm_session_->UpdateUsageEntryInformation());
|
||||
|
||||
@@ -2637,7 +2637,7 @@ TEST_F(DeviceFilesUsageInfoTest, ListNullParam) {
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
EXPECT_FALSE(device_files.ListUsageInfoFiles(NULL));
|
||||
EXPECT_FALSE(device_files.ListUsageInfoFiles(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesUsageInfoTest, ListIdsNull) {
|
||||
@@ -2647,7 +2647,7 @@ TEST_F(DeviceFilesUsageInfoTest, ListIdsNull) {
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
EXPECT_FALSE(device_files.ListUsageIds(app_id, NULL, NULL));
|
||||
EXPECT_FALSE(device_files.ListUsageIds(app_id, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesUsageInfoTest, ListUsageIds) {
|
||||
@@ -2873,7 +2873,7 @@ TEST_P(DeviceFilesUsageInfoTest, ListKeySetIds) {
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
|
||||
std::vector<std::string> key_set_ids;
|
||||
EXPECT_TRUE(device_files.ListUsageIds(app_id, &key_set_ids, NULL));
|
||||
EXPECT_TRUE(device_files.ListUsageIds(app_id, &key_set_ids, nullptr));
|
||||
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < key_set_ids.size(); ++i) {
|
||||
@@ -2925,7 +2925,7 @@ TEST_P(DeviceFilesUsageInfoTest, ListProviderSessionTokenIds) {
|
||||
|
||||
std::vector<std::string> provider_session_tokens;
|
||||
EXPECT_TRUE(
|
||||
device_files.ListUsageIds(app_id, NULL, &provider_session_tokens));
|
||||
device_files.ListUsageIds(app_id, nullptr, &provider_session_tokens));
|
||||
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < provider_session_tokens.size(); ++i) {
|
||||
|
||||
@@ -105,15 +105,15 @@ bool SocketWait(int fd, bool for_read, int timeout_in_ms) {
|
||||
tv.tv_sec = timeout_in_ms / 1000;
|
||||
tv.tv_usec = (timeout_in_ms % 1000) * 1000;
|
||||
|
||||
fd_set* read_fds = NULL;
|
||||
fd_set* write_fds = NULL;
|
||||
fd_set* read_fds = nullptr;
|
||||
fd_set* write_fds = nullptr;
|
||||
if (for_read) {
|
||||
read_fds = &fds;
|
||||
} else {
|
||||
write_fds = &fds;
|
||||
}
|
||||
|
||||
int ret = select(fd + 1, read_fds, write_fds, NULL, &tv);
|
||||
int ret = select(fd + 1, read_fds, write_fds, nullptr, &tv);
|
||||
if (ret == 0) {
|
||||
LOGE("socket timed out");
|
||||
return false;
|
||||
@@ -209,7 +209,7 @@ bool HttpSocket::ParseUrl(const std::string& url, std::string* scheme,
|
||||
}
|
||||
|
||||
HttpSocket::HttpSocket(const std::string& url)
|
||||
: socket_fd_(-1), ssl_(NULL), ssl_ctx_(NULL) {
|
||||
: socket_fd_(-1), ssl_(nullptr), ssl_ctx_(nullptr) {
|
||||
valid_url_ = ParseUrl(url, &scheme_, &secure_connect_, &domain_name_, &port_,
|
||||
&resource_path_);
|
||||
SSL_library_init();
|
||||
@@ -228,11 +228,11 @@ void HttpSocket::CloseSocket() {
|
||||
}
|
||||
if (ssl_) {
|
||||
SSL_free(ssl_);
|
||||
ssl_ = NULL;
|
||||
ssl_ = nullptr;
|
||||
}
|
||||
if (ssl_ctx_) {
|
||||
SSL_CTX_free(ssl_ctx_);
|
||||
ssl_ctx_ = NULL;
|
||||
ssl_ctx_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ bool HttpSocket::Connect(int timeout_in_ms) {
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
|
||||
|
||||
struct addrinfo* addr_info = NULL;
|
||||
struct addrinfo* addr_info = nullptr;
|
||||
int ret = getaddrinfo(domain_name_.c_str(), port_.c_str(), &hints,
|
||||
&addr_info);
|
||||
if (ret != 0) {
|
||||
@@ -413,7 +413,7 @@ int HttpSocket::Read(char* data, int len, int timeout_in_ms) {
|
||||
if (ssl_error == SSL_ERROR_SYSCALL) {
|
||||
LOGE(" errno = %d = %s", GetError(), GetErrorString());
|
||||
}
|
||||
ERR_print_errors_cb(LogBoringSslError, NULL);
|
||||
ERR_print_errors_cb(LogBoringSslError, nullptr);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -108,62 +108,62 @@ struct ParseUrlTests {
|
||||
|
||||
ParseUrlTests parse_url_tests[] = {
|
||||
{
|
||||
"https://code.google.com/p/googletest/wiki/Primer", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"443", // port
|
||||
"/p/googletest/wiki/Primer", // path
|
||||
"https://code.google.com/p/googletest/wiki/Primer", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"443", // port
|
||||
"/p/googletest/wiki/Primer", // path
|
||||
},
|
||||
{
|
||||
"http://code.google.com/p/googletest/wiki/Primer/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/p/googletest/wiki/Primer/", // path
|
||||
"http://code.google.com/p/googletest/wiki/Primer/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/p/googletest/wiki/Primer/", // path
|
||||
},
|
||||
{
|
||||
"http://code.google.com/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
"http://code.google.com/", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
},
|
||||
{
|
||||
"http://code.google.com", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
"http://code.google.com", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"code.google.com", // domain_name
|
||||
"80", // port
|
||||
"/", // path
|
||||
},
|
||||
{
|
||||
"http://10.11.12.13:8888/drm", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/drm", // path
|
||||
"http://10.11.12.13:8888/drm", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/drm", // path
|
||||
},
|
||||
{
|
||||
"http://10.11.12.13:8888", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
"http://10.11.12.13:8888", // url
|
||||
"http", // scheme
|
||||
false, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
},
|
||||
{
|
||||
"https://10.11.12.13:8888", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
"https://10.11.12.13:8888", // url
|
||||
"https", // scheme
|
||||
true, // secure_connect
|
||||
"10.11.12.13", // domain_name
|
||||
"8888", // port
|
||||
"/", // path
|
||||
},
|
||||
{NULL, NULL, false, NULL, 0, NULL} // list terminator
|
||||
{nullptr, nullptr, false, nullptr, 0, nullptr} // list terminator
|
||||
};
|
||||
|
||||
TEST_F(HttpSocketTest, ParseUrlTest) {
|
||||
@@ -172,9 +172,9 @@ TEST_F(HttpSocketTest, ParseUrlTest) {
|
||||
std::string domain_name;
|
||||
std::string port;
|
||||
std::string path;
|
||||
ParseUrlTests* test = NULL;
|
||||
ParseUrlTests* test = nullptr;
|
||||
|
||||
for (test = &parse_url_tests[0]; test->url != NULL; ++test) {
|
||||
for (test = &parse_url_tests[0]; test->url != nullptr; ++test) {
|
||||
bool ok = HttpSocket::ParseUrl(test->url, &scheme, &secure_connect,
|
||||
&domain_name, &port, &path);
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
@@ -107,10 +107,11 @@ class LicenseKeysTest : public ::testing::Test {
|
||||
virtual void AddContentKey(
|
||||
const KeyId& key_id, bool set_level = false,
|
||||
KeyContainer::SecurityLevel level = KeyContainer::SW_SECURE_CRYPTO,
|
||||
bool set_hdcp = false, KeyContainer::OutputProtection::HDCP hdcp_value =
|
||||
bool set_hdcp = false,
|
||||
KeyContainer::OutputProtection::HDCP hdcp_value =
|
||||
KeyContainer::OutputProtection::HDCP_NONE,
|
||||
bool set_constraints = false,
|
||||
std::vector<VideoResolutionConstraint>* constraints = NULL) {
|
||||
std::vector<VideoResolutionConstraint>* constraints = nullptr) {
|
||||
KeyContainer* key = license_.add_key();
|
||||
key->set_type(KeyContainer::CONTENT);
|
||||
if (set_level) {
|
||||
@@ -141,7 +142,7 @@ class LicenseKeysTest : public ::testing::Test {
|
||||
KeyContainer::OutputProtection::HDCP hdcp_value =
|
||||
KeyContainer::OutputProtection::HDCP_NONE,
|
||||
bool set_constraints = false,
|
||||
std::vector<VideoResolutionConstraint>* constraints = NULL) {
|
||||
std::vector<VideoResolutionConstraint>* constraints = nullptr) {
|
||||
AddContentKey(key_id, set_level, level, set_hdcp, hdcp_value,
|
||||
set_constraints, constraints);
|
||||
license_.mutable_key(license_.key_size() - 1)
|
||||
|
||||
@@ -155,7 +155,7 @@ class MockCryptoSession : public TestCryptoSession {
|
||||
class MockPolicyEngine : public PolicyEngine {
|
||||
public:
|
||||
MockPolicyEngine(CryptoSession* crypto)
|
||||
: PolicyEngine("mock_session_id", NULL, crypto) {}
|
||||
: PolicyEngine("mock_session_id", nullptr, crypto) {}
|
||||
MOCK_METHOD1(SetEntitledLicenseKeys,
|
||||
void(const std::vector<video_widevine::WidevinePsshData_EntitledKey>&));
|
||||
};
|
||||
@@ -234,7 +234,7 @@ class CdmLicenseTest : public WvCdmTestBase {
|
||||
|
||||
virtual void CreateCdmLicense() {
|
||||
cdm_license_ = new CdmLicenseTestPeer(kCdmSessionId, clock_);
|
||||
clock_ = NULL;
|
||||
clock_ = nullptr;
|
||||
}
|
||||
|
||||
CdmLicenseTestPeer* cdm_license_;
|
||||
@@ -265,7 +265,7 @@ TEST_F(CdmLicenseTest, InitFail_EmptyToken) {
|
||||
TEST_F(CdmLicenseTest, InitFail_CryptoSessionNull) {
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", false,
|
||||
kEmptyServiceCertificate, NULL,
|
||||
kEmptyServiceCertificate, nullptr,
|
||||
policy_engine_));
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ TEST_F(CdmLicenseTest, InitFail_PolicyEngineNull) {
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", false,
|
||||
kEmptyServiceCertificate, crypto_session_,
|
||||
NULL));
|
||||
nullptr));
|
||||
}
|
||||
|
||||
TEST_F(CdmLicenseTest, InitWithEmptyServiceCert) {
|
||||
|
||||
@@ -1974,7 +1974,8 @@ class PolicyEngineQueryTest : public PolicyEngineTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
PolicyEngineTest::SetUp();
|
||||
policy_engine_.reset(new PolicyEngine(kSessionId, NULL, &crypto_session_));
|
||||
policy_engine_.reset(
|
||||
new PolicyEngine(kSessionId, nullptr, &crypto_session_));
|
||||
InjectMockClock();
|
||||
|
||||
// Use a STREAMING license policy.
|
||||
|
||||
@@ -330,12 +330,12 @@ void WvCdmTestBase::EnsureProvisioned() {
|
||||
FileSystem file_system;
|
||||
CdmEngine cdm_engine(&file_system,
|
||||
std::shared_ptr<EngineMetrics>(new EngineMetrics));
|
||||
CdmResponseType status =
|
||||
cdm_engine.OpenSession(config_.key_system(), NULL, NULL, &session_id);
|
||||
CdmResponseType status = cdm_engine.OpenSession(config_.key_system(), nullptr,
|
||||
nullptr, &session_id);
|
||||
if (status == NEED_PROVISIONING) {
|
||||
Provision();
|
||||
status =
|
||||
cdm_engine.OpenSession(config_.key_system(), NULL, NULL, &session_id);
|
||||
status = cdm_engine.OpenSession(config_.key_system(), nullptr, nullptr,
|
||||
&session_id);
|
||||
}
|
||||
ASSERT_EQ(NO_ERROR, status);
|
||||
ASSERT_NE("", session_id) << "Could not open CDM session.";
|
||||
@@ -445,7 +445,7 @@ TestLicenseHolder::~TestLicenseHolder() {
|
||||
|
||||
void TestLicenseHolder::OpenSession(const std::string& key_system) {
|
||||
CdmResponseType status =
|
||||
cdm_engine_->OpenSession(key_system, NULL, NULL, &session_id_);
|
||||
cdm_engine_->OpenSession(key_system, nullptr, nullptr, &session_id_);
|
||||
ASSERT_EQ(status, NO_ERROR);
|
||||
ASSERT_NE("", session_id_) << "Could not open CDM session.";
|
||||
ASSERT_TRUE(cdm_engine_->IsOpenSession(session_id_));
|
||||
@@ -624,7 +624,7 @@ void TestLicenseHolder::DeriveKeysFromSessionKey() {
|
||||
bool TestLicenseHolder::DeriveKey(const std::vector<uint8_t>& key,
|
||||
const std::vector<uint8_t>& context,
|
||||
int counter, std::vector<uint8_t>* out) {
|
||||
if (key.empty() || counter > 4 || context.empty() || out == NULL) {
|
||||
if (key.empty() || counter > 4 || context.empty() || out == nullptr) {
|
||||
LOGE("DeriveKey(): bad context");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,9 +333,9 @@ class UsageTableHeaderTest : public WvCdmTestBase {
|
||||
// UsageTableHeaderTest maintains ownership of returned pointer
|
||||
MockUsageTableHeader* SetUpMock() {
|
||||
// Release non-mocked usage table header
|
||||
if (usage_table_header_ != NULL) {
|
||||
if (usage_table_header_ != nullptr) {
|
||||
delete usage_table_header_;
|
||||
usage_table_header_ = NULL;
|
||||
usage_table_header_ = nullptr;
|
||||
}
|
||||
|
||||
// Create new mock objects if using MockUsageTableHeader
|
||||
@@ -352,7 +352,7 @@ class UsageTableHeaderTest : public WvCdmTestBase {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (usage_table_header_ != NULL) delete usage_table_header_;
|
||||
if (usage_table_header_ != nullptr) delete usage_table_header_;
|
||||
}
|
||||
|
||||
void Init(CdmSecurityLevel security_level,
|
||||
@@ -379,8 +379,8 @@ TEST_F(UsageTableHeaderTest, InitError) {
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL2, crypto_session_));
|
||||
EXPECT_FALSE(
|
||||
usage_table_header_->Init(kSecurityLevelUnknown, crypto_session_));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL1, NULL));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL2, NULL));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL1, nullptr));
|
||||
EXPECT_FALSE(usage_table_header_->Init(kSecurityLevelL2, nullptr));
|
||||
}
|
||||
|
||||
class UsageTableHeaderInitializationTest
|
||||
|
||||
Reference in New Issue
Block a user