From: gameblabla Date: Thu, 18 Jul 2019 00:13:13 +0000 (+0200) Subject: psxbios: Add checks for bcopy X-Git-Tag: r23~156^2~32 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0148ffb739a05e87ed9eaaf623c754d3d50ee2ab;p=pcsx_rearmed.git psxbios: Add checks for bcopy Nocash documentation say that function refuses to copy any data if dst is NULL or len greater than 0x7FFFFFFF. (In any cases, return value is always dst) --- diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 67a01e5a..4019234b 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -739,15 +739,20 @@ void psxBios_tolower() { // 0x26 void psxBios_bcopy() { // 0x27 char *p1 = (char *)Ra1, *p2 = (char *)Ra0; + v0 = a0; + if (a0 == 0 || a2 > 0x7FFFFFFF) + { + pc0 = ra; + return; + } while ((s32)a2-- > 0) *p1++ = *p2++; - + a2 = 0; pc0 = ra; } void psxBios_bzero() { // 0x28 char *p = (char *)Ra0; while ((s32)a1-- > 0) *p++ = '\0'; - pc0 = ra; }