mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(relinker): share RELA entry bounds check with extractRelative
This commit is contained in:
committed by
Adrià Franch
parent
cfba9c09d2
commit
9ff9d4325c
@@ -185,11 +185,15 @@ RelinkResult RelinkerPipeline::Relink(const std::vector<std::uint8_t>& sourceElf
|
||||
throw RelinkerException("Duplicate import module ID");
|
||||
}
|
||||
|
||||
auto relaEntryPos = [&](const FileByteOffset relaOff, const ByteCount off) -> FileByteOffset {
|
||||
if (relaOff > raw.size() || off > raw.size() - relaOff || relaEntSize > raw.size() - relaOff - off)
|
||||
throw RelinkerException("Relocation entry out of bounds", relaOff);
|
||||
return relaOff + off;
|
||||
};
|
||||
|
||||
auto extractRela = [&](const FileByteOffset relaOff, const ByteCount relaSize) {
|
||||
for (ByteCount off = 0; relaSize >= relaEntSize && off <= relaSize - relaEntSize; off += relaEntSize) {
|
||||
if (relaOff > raw.size() || off > raw.size() - relaOff || relaEntSize > raw.size() - relaOff - off)
|
||||
throw RelinkerException("Relocation entry out of bounds", relaOff);
|
||||
const FileByteOffset pos = relaOff + off;
|
||||
const FileByteOffset pos = relaEntryPos(relaOff, off);
|
||||
|
||||
std::uint64_t rOffset = 0, rInfo = 0;
|
||||
std::int64_t rAddend = 0;
|
||||
@@ -291,8 +295,8 @@ RelinkResult RelinkerPipeline::Relink(const std::vector<std::uint8_t>& sourceElf
|
||||
};
|
||||
|
||||
auto extractRelative = [&](const FileByteOffset relaOff, const ByteCount relaSize) {
|
||||
for (ByteCount off = 0; off + relaEntSize <= relaSize; off += relaEntSize) {
|
||||
const FileByteOffset pos = relaOff + off;
|
||||
for (ByteCount off = 0; relaSize >= relaEntSize && off <= relaSize - relaEntSize; off += relaEntSize) {
|
||||
const FileByteOffset pos = relaEntryPos(relaOff, off);
|
||||
std::uint64_t rOffset = 0, rInfo = 0;
|
||||
std::int64_t rAddend = 0;
|
||||
std::memcpy(&rOffset, raw.data() + pos, 8);
|
||||
|
||||
Reference in New Issue
Block a user