diff options
| author | 2018-10-03 02:13:49 -0400 | |
|---|---|---|
| committer | 2018-10-03 02:13:51 -0400 | |
| commit | 024eec02a59d5902e3731a7120ebc97846b34991 (patch) | |
| tree | 6a16ff9f6b33deaca6a4a70226d5527cc3570b54 /src/core | |
| parent | submission_package: Correct location of null check within SetTicketKeys() (diff) | |
| download | yuzu-024eec02a59d5902e3731a7120ebc97846b34991.tar.gz yuzu-024eec02a59d5902e3731a7120ebc97846b34991.tar.xz yuzu-024eec02a59d5902e3731a7120ebc97846b34991.zip | |
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.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/submission_package.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 829aca06f..09bf077cd 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp | |||
| @@ -38,8 +38,11 @@ void SetTicketKeys(const std::vector<VirtualFile>& files) { | |||
| 38 | 38 | ||
| 39 | Core::Crypto::Key128 key{}; | 39 | Core::Crypto::Key128 key{}; |
| 40 | ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET); | 40 | ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET); |
| 41 | std::string_view name_only(ticket_file->GetName()); | 41 | |
| 42 | name_only.remove_suffix(4); | 42 | // We get the name without the extension in order to create the rights ID. |
| 43 | std::string name_only(ticket_file->GetName()); | ||
| 44 | name_only.erase(name_only.size() - 4); | ||
| 45 | |||
| 43 | const auto rights_id_raw = Common::HexStringToArray<16>(name_only); | 46 | const auto rights_id_raw = Common::HexStringToArray<16>(name_only); |
| 44 | u128 rights_id; | 47 | u128 rights_id; |
| 45 | std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128)); | 48 | std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128)); |