submission_package: Avoid dangling std::string_view within SetTicketKeys()
GetName() returns a std::string by value, not by reference, so after the std::string_view is constructed, it's not well defined to actually execute any member functions of std::string_view that attempt to access the data, as the std::string has already been destroyed. Instead, we can just use a std::string and erase the last four characters.
This commit is contained in:
parent
dade709f63
commit
024eec02a5
|
@ -38,8 +38,11 @@ void SetTicketKeys(const std::vector<VirtualFile>& files) {
|
||||||
|
|
||||||
Core::Crypto::Key128 key{};
|
Core::Crypto::Key128 key{};
|
||||||
ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET);
|
ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET);
|
||||||
std::string_view name_only(ticket_file->GetName());
|
|
||||||
name_only.remove_suffix(4);
|
// We get the name without the extension in order to create the rights ID.
|
||||||
|
std::string name_only(ticket_file->GetName());
|
||||||
|
name_only.erase(name_only.size() - 4);
|
||||||
|
|
||||||
const auto rights_id_raw = Common::HexStringToArray<16>(name_only);
|
const auto rights_id_raw = Common::HexStringToArray<16>(name_only);
|
||||||
u128 rights_id;
|
u128 rights_id;
|
||||||
std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128));
|
std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128));
|
||||||
|
|
Loading…
Reference in New Issue