libwhb: Use an aligned buffer size for WHBReadWholeFile to avoid potential heap corruption (#212)

This commit is contained in:
Maschell 2022-03-04 12:52:40 +01:00 committed by GitHub
parent 616ebe1a06
commit b23f9bde00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,9 +138,9 @@ WHBReadWholeFile(const char *path,
goto error;
}
buf = MEMAllocFromDefaultHeapEx(size, 64);
buf = MEMAllocFromDefaultHeapEx((size + 0x3F) & ~(0x3F), 64);
if (!buf) {
WHBLogPrintf("%s: MEMAllocFromDefaultHeapEx(0x%X, 64) failed", __FUNCTION__, size);
WHBLogPrintf("%s: MEMAllocFromDefaultHeapEx(0x%X, 64) failed", __FUNCTION__, (size + 0x3F) & ~(0x3F));
goto error;
}