08-25-2012, 06:53 PM
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:
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:
Another problem is line 527:
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:
Finally, I believe line 531 should be:
Code:
505 fileOutput.write(outBuf, 0, Math.min(length, outBuf.length));
Code:
505 fileOutput.write(outBuf);
Another problem is line 527:
Code:
527 int length = Math.min(outBuf.length, Math.min(fileSize, maxLength));
Code:
527 int length = Math.min(outBuf.length, maxLength);
Finally, I believe line 531 should be:
Code:
531 return length;