mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-04 15:19:09 +00:00
HW/CEXIIPL: Respect bounds in LoadFileToIPL().
This commit is contained in:
parent
f284bfca45
commit
7d53916466
1 changed files with 7 additions and 2 deletions
|
@ -159,13 +159,18 @@ void CEXIIPL::DoState(PointerWrap& p)
|
||||||
|
|
||||||
bool CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset)
|
bool CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset)
|
||||||
{
|
{
|
||||||
|
if (offset >= ROM_SIZE)
|
||||||
|
return false;
|
||||||
|
|
||||||
File::IOFile stream(filename, "rb");
|
File::IOFile stream(filename, "rb");
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
u64 filesize = stream.GetSize();
|
const u64 filesize = stream.GetSize();
|
||||||
|
if (offset >= filesize)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!stream.ReadBytes(&m_rom[offset], filesize))
|
if (!stream.ReadBytes(&m_rom[offset], std::min<u64>(filesize, ROM_SIZE) - offset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_fonts_loaded = true;
|
m_fonts_loaded = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue