Skip to content

Cp/r136659551 dont crash on malformed corefile #9344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
}
}

void DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
bool DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
ImageInfo &image_info) {
if (image_info.header.filetype == llvm::MachO::MH_DYLINKER) {
const bool can_create = true;
Expand All @@ -605,8 +605,10 @@ void DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
target.GetImages().AppendIfNeeded(dyld_sp);
UpdateImageLoadAddress(dyld_sp.get(), image_info);
SetDYLDModule(dyld_sp);
return true;
}
}
return false;
}

std::optional<lldb_private::Address> DynamicLoaderDarwin::GetStartAddress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader {
UpdateSpecialBinariesFromNewImageInfos(ImageInfo::collection &image_infos);

// if image_info is a dyld binary, call this method
void UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info);
bool UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info);

// If image_infos contains / may contain executable image, call this method
// to keep our internal record keeping of the special dyld binary up-to-date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,13 @@ bool DynamicLoaderMacOSXDYLD::ReadDYLDInfoFromMemoryAndSetNotificationCallback(
ModuleSP dyld_module_sp;
if (ParseLoadCommands(data, m_dyld, &m_dyld.file_spec)) {
if (m_dyld.file_spec) {
UpdateDYLDImageInfoFromNewImageInfo(m_dyld);
if (!UpdateDYLDImageInfoFromNewImageInfo(m_dyld))
return false;
}
}
dyld_module_sp = GetDYLDModule();
if (!dyld_module_sp)
return false;

Target &target = m_process->GetTarget();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ void ObjectFileMachO::SanitizeSegmentCommand(
seg_cmd.cmd == LC_SEGMENT_64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
GetModule()->ReportWarning(
"load command {0} {1} has a fileoff + filesize ({2:x16}) that "
"extends beyond the end of the file ({4:x16}), the segment will be "
"extends beyond the end of the file ({3:x16}), the segment will be "
"truncated to match",
cmd_idx, lc_segment_name, seg_cmd.fileoff + seg_cmd.filesize, m_length);

Expand Down