[es] Fix bugs where member variables were not applied when copied.

This commit is contained in:
jakcron 2018-07-04 13:35:35 +08:00
parent ab029cd936
commit 16041c2d65

View file

@ -26,6 +26,7 @@ void es::TicketBody_V2::operator=(const TicketBody_V2 & other)
mEncType = other.mEncType; mEncType = other.mEncType;
mTicketVersion = other.mTicketVersion; mTicketVersion = other.mTicketVersion;
mLicenseType = other.mLicenseType; mLicenseType = other.mLicenseType;
mCommonKeyId = other.mCommonKeyId;
mPreInstall = other.mPreInstall; mPreInstall = other.mPreInstall;
mSharedTitle = other.mSharedTitle; mSharedTitle = other.mSharedTitle;
mAllowAllContent = other.mAllowAllContent; mAllowAllContent = other.mAllowAllContent;
@ -74,10 +75,12 @@ void es::TicketBody_V2::toBytes()
body->format_version = (ticket::kFormatVersion); body->format_version = (ticket::kFormatVersion);
strncmp(body->issuer, mIssuer.c_str(), ticket::kIssuerSize); strncpy(body->issuer, mIssuer.c_str(), ticket::kIssuerSize);
memcpy(body->enc_title_key, mEncTitleKey, ticket::kEncTitleKeySize); memcpy(body->enc_title_key, mEncTitleKey, ticket::kEncTitleKeySize);
body->title_key_enc_type = (mEncType); body->title_key_enc_type = (mEncType);
body->ticket_version = (mTicketVersion); body->ticket_version = (mTicketVersion);
body->license_type = mLicenseType;
body->common_key_id = mCommonKeyId;
byte_t property_mask = 0; byte_t property_mask = 0;
property_mask |= mPreInstall ? _BIT(ticket::FLAG_PRE_INSTALL) : 0; property_mask |= mPreInstall ? _BIT(ticket::FLAG_PRE_INSTALL) : 0;
property_mask |= mSharedTitle ? _BIT(ticket::FLAG_SHARED_TITLE) : 0; property_mask |= mSharedTitle ? _BIT(ticket::FLAG_SHARED_TITLE) : 0;
@ -117,6 +120,7 @@ void es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len)
mEncType = (ticket::TitleKeyEncType)body->title_key_enc_type; mEncType = (ticket::TitleKeyEncType)body->title_key_enc_type;
mTicketVersion = body->ticket_version.get(); mTicketVersion = body->ticket_version.get();
mLicenseType = (ticket::LicenseType)body->license_type; mLicenseType = (ticket::LicenseType)body->license_type;
mCommonKeyId = body->common_key_id;
mPreInstall = _HAS_BIT(body->property_mask, ticket::FLAG_PRE_INSTALL); mPreInstall = _HAS_BIT(body->property_mask, ticket::FLAG_PRE_INSTALL);
mSharedTitle = _HAS_BIT(body->property_mask, ticket::FLAG_SHARED_TITLE); mSharedTitle = _HAS_BIT(body->property_mask, ticket::FLAG_SHARED_TITLE);
mAllowAllContent = _HAS_BIT(body->property_mask, ticket::FLAG_ALLOW_ALL_CONTENT); mAllowAllContent = _HAS_BIT(body->property_mask, ticket::FLAG_ALLOW_ALL_CONTENT);
@ -144,6 +148,7 @@ void es::TicketBody_V2::clear()
mEncType = ticket::AES128_CBC; mEncType = ticket::AES128_CBC;
mTicketVersion = 0; mTicketVersion = 0;
mLicenseType = ticket::LICENSE_PERMANENT; mLicenseType = ticket::LICENSE_PERMANENT;
mCommonKeyId = 0;
mPreInstall = false; mPreInstall = false;
mSharedTitle = false; mSharedTitle = false;
mAllowAllContent = false; mAllowAllContent = false;