mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Core/Movie: Fix a likely out-of-bounds read for PanicAlertT
gameID isn't null terminated since it is just an std::array<char, 6> and .data() returns a char* so {fmt} would go way beyond the bounds of the array when it attempts to determine the length of the string. The fix is to pass a std::string_view to {fmt}. This commit adds a GetGameID() function that can also be used to simplify string comparisons.
This commit is contained in:
@ -227,10 +227,10 @@ void Init(const BootParameters& boot)
|
||||
ReadHeader();
|
||||
std::thread md5thread(CheckMD5);
|
||||
md5thread.detach();
|
||||
if (strncmp(tmpHeader.gameID.data(), SConfig::GetInstance().GetGameID().c_str(), 6))
|
||||
if (tmpHeader.GetGameID() == SConfig::GetInstance().GetGameID())
|
||||
{
|
||||
PanicAlertFmtT("The recorded game ({0}) is not the same as the selected game ({1})",
|
||||
tmpHeader.gameID.data(), SConfig::GetInstance().GetGameID());
|
||||
tmpHeader.GetGameID(), SConfig::GetInstance().GetGameID());
|
||||
EndPlayInput(false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user