summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorNicola Vella <nicola.vella@hotmail.com>2023-10-08 11:37:43 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2023-10-08 15:13:41 +0200
commitb506bdc4018095dc4bc612a5b12837b3dfeb2d76 (patch)
treed225c6087f10b5d52a71d5bf638fbbc130bd8e47 /Source/Core
parent31dfb53152bc22f2ad1aab4fdd13c01b67444d2d (diff)
Fix heap buffer overflow in GCMemcardRaw
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h
index 067f795401..3138899667 100644
--- a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h
+++ b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.h
@@ -30,7 +30,11 @@ public:
void DoState(PointerWrap& p) override;
private:
- bool IsAddressInBounds(u32 address, u32 length) const { return address + length <= (m_memory_card_size - 1); }
+ bool IsAddressInBounds(u32 address, u32 length) const
+ {
+ u64 end_address = static_cast<u64>(address) + static_cast<u64>(length);
+ return end_address <= static_cast<u64>(m_memory_card_size);
+ }
std::string m_filename;
std::unique_ptr<u8[]> m_memcard_data;