aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authorgameblabla2019-07-18 01:55:57 +0200
committergameblabla2019-07-18 01:55:57 +0200
commitbd48ba5ea8c87bf8c771550bc5320f7e6f73c9a6 (patch)
tree48dfb8f5a7f91e2fbfe9a11bbfe3c3651b901ec1 /libpcsxcore
parent76b81516963f0f50049be59172c651b559d9fabf (diff)
downloadpcsx_rearmed-bd48ba5ea8c87bf8c771550bc5320f7e6f73c9a6.tar.gz
pcsx_rearmed-bd48ba5ea8c87bf8c771550bc5320f7e6f73c9a6.tar.bz2
pcsx_rearmed-bd48ba5ea8c87bf8c771550bc5320f7e6f73c9a6.zip
psxbios: Add checks for card_write, card_read
This also implements a bug which allows writes to 0x400 (Is supposed to only accept sector number between 0..3FFh). Function should return 0 if sector is invalid.
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/psxbios.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c
index 265dbfd..d4a38e1 100644
--- a/libpcsxcore/psxbios.c
+++ b/libpcsxcore/psxbios.c
@@ -2146,7 +2146,13 @@ void psxBios__card_write() { // 0x4e
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %x,%x,%x\n", biosB0n[0x4e], a0, a1, a2);
#endif
-
+ /* Function also accepts sector 400h (a bug) */
+ if (!(a1 <= 0x400))
+ {
+ /* Invalid sectors */
+ v0 = 0; pc0 = ra;
+ return;
+ }
card_active_chan = a0;
port = a0 >> 4;
@@ -2173,7 +2179,13 @@ void psxBios__card_read() { // 0x4f
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosB0n[0x4f]);
#endif
-
+ /* Function also accepts sector 400h (a bug) */
+ if (!(a1 <= 0x400))
+ {
+ /* Invalid sectors */
+ v0 = 0; pc0 = ra;
+ return;
+ }
card_active_chan = a0;
port = a0 >> 4;