Correct two minor bugs causing reported crashes

This commit is contained in:
Henrik Rydgård
2026-03-13 10:16:25 +01:00
parent 70fa516d75
commit 56be37a2e4
2 changed files with 10 additions and 5 deletions
+3 -3
View File
@@ -1096,8 +1096,8 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
// In this case it's definitely not compressed. Added assert below.
}
// Don't accept ELFs over 24MB.
if (decryptedSize > 24 * 1024 * 1024) {
// Don't accept ELFs over 24MB - nor ones with negative size, of course.
if (decryptedSize < 0 || decryptedSize > 24 * 1024 * 1024) {
*error_string = StringFromFormat("ELF/PRX corrupt, unreasonable decrypted size: %d", (u32)decryptedSize);
// TODO: Might be the wrong error code.
error = SCE_KERNEL_ERROR_FILEERR;
@@ -1110,7 +1110,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
// Can't decompress in place so we need a temporary buffer.
u8 *temp = (u8 *)malloc(decryptedSize);
_assert_msg_(temp != nullptr, "Failed to allocate gzip decompression buffer");
_assert_msg_(temp != nullptr, "Failed to allocate gzip decompression buffer (decryptedSize: %d)", decryptedSize);
memcpy(temp, ptr, decryptedSize);
int outBytes = gzipDecompress((u8 *)ptr, maxElfSize, temp);
if (outBytes < 0) {