EmuNewz Network

Full Version: Savefile corruption in r2690
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The changes in r2690, specifically jpcsp.HLE.kernel.types.SceUtilitySavedataParam are causing savefile corruption when savedata crypto mode is enabled. Line 505 is truncating the encrypted savedata improperly:
Code:
505    fileOutput.write(outBuf, 0, Math.min(length, outBuf.length));
The CryptoEngine produces encrypted savedata that is a few bytes larger than the original savedata, so forcing the encrypted output to be same length as the original is causing the data corruption. I believe line 505 should be reverted to:
Code:
505    fileOutput.write(outBuf);

Another problem is line 527:
Code:
527    int length = Math.min(outBuf.length, Math.min(fileSize, maxLength));
As long as the decrypted data is smaller than the encrypted data, then this code is harmless. However, if it ever happens that the decrypted data is bigger than the encrypted data, then improper truncation will occur during loading. I think the proper code should be:
Code:
527    int length = Math.min(outBuf.length, maxLength);

Finally, I believe line 531 should be:
Code:
531    return length;
This should now be fixed as suggested in r2704.
Thank you for reviewing the code! Smile