mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-12-01 18:15:41 +00:00
Achievements: Fix potential uninitialized data read
This commit is contained in:
parent
8698298499
commit
500fbe5ef1
|
@ -275,7 +275,7 @@ std::string Achievements::GetGameHash(CDImage* image)
|
||||||
if (!System::ReadExecutableFromImage(image, &executable_name, &executable_data))
|
if (!System::ReadExecutableFromImage(image, &executable_name, &executable_data))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
BIOS::PSEXEHeader header;
|
BIOS::PSEXEHeader header = {};
|
||||||
if (executable_data.size() >= sizeof(header))
|
if (executable_data.size() >= sizeof(header))
|
||||||
std::memcpy(&header, executable_data.data(), sizeof(header));
|
std::memcpy(&header, executable_data.data(), sizeof(header));
|
||||||
if (!BIOS::IsValidPSExeHeader(header, static_cast<u32>(executable_data.size())))
|
if (!BIOS::IsValidPSExeHeader(header, static_cast<u32>(executable_data.size())))
|
||||||
|
@ -286,8 +286,8 @@ std::string Achievements::GetGameHash(CDImage* image)
|
||||||
|
|
||||||
// See rcheevos hash.c - rc_hash_psx().
|
// See rcheevos hash.c - rc_hash_psx().
|
||||||
const u32 MAX_HASH_SIZE = 64 * 1024 * 1024;
|
const u32 MAX_HASH_SIZE = 64 * 1024 * 1024;
|
||||||
const u32 hash_size = std::min<u32>(sizeof(header) + header.file_size, MAX_HASH_SIZE);
|
const u32 hash_size =
|
||||||
Assert(hash_size <= executable_data.size());
|
std::min(std::min<u32>(sizeof(header) + header.file_size, MAX_HASH_SIZE), static_cast<u32>(executable_data.size()));
|
||||||
|
|
||||||
MD5Digest digest;
|
MD5Digest digest;
|
||||||
digest.Update(executable_name.c_str(), static_cast<u32>(executable_name.size()));
|
digest.Update(executable_name.c_str(), static_cast<u32>(executable_name.size()));
|
||||||
|
|
Loading…
Reference in a new issue