mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-06 01:48:14 -04:00
Avoid overlay files overflowing solid heaps (#2387)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <limits>
|
||||
#include <ranges>
|
||||
#include <string_view>
|
||||
#include <borealis/log.hpp>
|
||||
#include "JSystem/JKernel/JKRDvdRipper.h"
|
||||
#if _WIN32
|
||||
#include <malloc.h>
|
||||
@@ -21,6 +22,8 @@ std::atomic<u64> JKRArchive::sArcOverlayGeneration{0};
|
||||
|
||||
namespace {
|
||||
|
||||
inline constexpr borealis::Log Log{"JKRArchivePri"};
|
||||
|
||||
void* alloc_overlay_buffer(u32 size) {
|
||||
#if _WIN32
|
||||
return _aligned_malloc(size, alignof(std::max_align_t));
|
||||
@@ -452,12 +455,18 @@ bool JKRArchive::copyOverlayData(void* buffer, u32 bufferSize, SDIFileEntry* ent
|
||||
return false;
|
||||
}
|
||||
|
||||
const u32 copySize = overlaySize < bufferSize ? overlaySize : bufferSize;
|
||||
if (copySize != 0) {
|
||||
memcpy(buffer, overlayData, copySize);
|
||||
if (overlaySize > bufferSize) {
|
||||
std::string path;
|
||||
getOverlayPath(entry, path);
|
||||
Log.error("Overlay %s is %u bytes but the game reserved %u\n", path.c_str(), overlaySize,
|
||||
bufferSize);
|
||||
return false;
|
||||
}
|
||||
if (overlaySize != 0) {
|
||||
memcpy(buffer, overlayData, overlaySize);
|
||||
}
|
||||
if (outSize != nullptr) {
|
||||
*outSize = copySize;
|
||||
*outSize = overlaySize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user