GP-0: Safeguarding Mach-O sections living outside of their segment

during Program Tree creation (Closes #6865)
This commit is contained in:
Ryan Kurtz 2024-08-30 08:46:03 -04:00
parent 916c0bbf10
commit 184180d54d

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -433,6 +433,11 @@ public class MachoProgramBuilder {
}
Address sectionStart = segmentSpace.getAddress(section.getAddress());
Address sectionEnd = sectionStart.add(section.getSize() - 1);
if (!memory.contains(sectionStart)) {
log.appendMsg("Warning: Section %s.%s is not contained within its segment"
.formatted(section.getSegmentName(), section.getSectionName()));
continue;
}
if (!memory.contains(sectionEnd)) {
sectionEnd = memory.getBlock(sectionStart).getEnd();
}