Skip to content

Commit 9400302

Browse files
authored
Merge pull request #9344 from jasonmolenda/cp/r136659551-dont-crash-on-malformed-corefile
Cp/r136659551 dont crash on malformed corefile
2 parents 4d01184 + 8f8a9b4 commit 9400302

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
594594
}
595595
}
596596

597-
void DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
597+
bool DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
598598
ImageInfo &image_info) {
599599
if (image_info.header.filetype == llvm::MachO::MH_DYLINKER) {
600600
const bool can_create = true;
@@ -605,8 +605,10 @@ void DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
605605
target.GetImages().AppendIfNeeded(dyld_sp);
606606
UpdateImageLoadAddress(dyld_sp.get(), image_info);
607607
SetDYLDModule(dyld_sp);
608+
return true;
608609
}
609610
}
611+
return false;
610612
}
611613

612614
std::optional<lldb_private::Address> DynamicLoaderDarwin::GetStartAddress() {

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader {
208208
UpdateSpecialBinariesFromNewImageInfos(ImageInfo::collection &image_infos);
209209

210210
// if image_info is a dyld binary, call this method
211-
void UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info);
211+
bool UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info);
212212

213213
// If image_infos contains / may contain executable image, call this method
214214
// to keep our internal record keeping of the special dyld binary up-to-date.

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,13 @@ bool DynamicLoaderMacOSXDYLD::ReadDYLDInfoFromMemoryAndSetNotificationCallback(
259259
ModuleSP dyld_module_sp;
260260
if (ParseLoadCommands(data, m_dyld, &m_dyld.file_spec)) {
261261
if (m_dyld.file_spec) {
262-
UpdateDYLDImageInfoFromNewImageInfo(m_dyld);
262+
if (!UpdateDYLDImageInfoFromNewImageInfo(m_dyld))
263+
return false;
263264
}
264265
}
265266
dyld_module_sp = GetDYLDModule();
267+
if (!dyld_module_sp)
268+
return false;
266269

267270
Target &target = m_process->GetTarget();
268271

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ void ObjectFileMachO::SanitizeSegmentCommand(
14121412
seg_cmd.cmd == LC_SEGMENT_64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
14131413
GetModule()->ReportWarning(
14141414
"load command {0} {1} has a fileoff + filesize ({2:x16}) that "
1415-
"extends beyond the end of the file ({4:x16}), the segment will be "
1415+
"extends beyond the end of the file ({3:x16}), the segment will be "
14161416
"truncated to match",
14171417
cmd_idx, lc_segment_name, seg_cmd.fileoff + seg_cmd.filesize, m_length);
14181418

0 commit comments

Comments
 (0)