diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 54a70b761594..e8148574dd0e 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -1335,7 +1335,12 @@ bool SELFDecrypter::GetKeyFromRap(u8* content_id, u8* npdrm_key) } self_log.notice("Loading RAP file %s.rap", ci_str); - rap_file.read(rap_key, 0x10); + + if (rap_file.read(rap_key, 0x10) != 0x10) + { + self_log.fatal("Failed to load %s: RAP file exists but is invalid. Try reinstalling it.", rap_path); + return false; + } // Convert the RAP key. rap_to_rif(rap_key, npdrm_key); diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index b4dea9b9bd51..fdec775829d3 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -557,7 +557,7 @@ error_code sceNpDrmVerifyUpgradeLicense(vm::cptr content_id) sceNp.warning(u8"sceNpDrmVerifyUpgradeLicense(): content_id=ā€œ%sā€", content_id); - if (!fs::is_file(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/" + content_str + ".rap"))) + if (fs::stat_t s{}; !fs::stat(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/" + content_str + ".rap"), s) || s.size < 0x10) { // Game hasn't been purchased therefore no RAP file present return SCE_NP_DRM_ERROR_LICENSE_NOT_FOUND; @@ -580,7 +580,7 @@ error_code sceNpDrmVerifyUpgradeLicense2(vm::cptr content_id) sceNp.warning(u8"sceNpDrmVerifyUpgradeLicense2(): content_id=ā€œ%sā€", content_id); - if (!fs::is_file(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/" + content_str + ".rap"))) + if (fs::stat_t s{}; !fs::stat(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/" + content_str + ".rap"), s) || s.size < 0x10) { // Game hasn't been purchased therefore no RAP file present return SCE_NP_DRM_ERROR_LICENSE_NOT_FOUND;