Check the size of of the dyld_all_image_infos structure before using it

After 6083a2706d55, it is possible to determine the expected size of a
versioned structure such as dyld_all_image_infos. The expected size is
compared against the actual size of the structure as returned by
task_info() (TASK_DYLD_INFO).

TEST=crashpad_snapshot_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1272283004 .
This commit is contained in:
Mark Mentovai 2015-08-13 12:55:41 -04:00
parent ad09fd1bc8
commit e74922936d

View File

@ -374,7 +374,21 @@ void ProcessReader::InitializeModules() {
return;
}
DCHECK_GE(all_image_infos.version, 1u);
if (all_image_infos.version < 1) {
LOG(WARNING) << "unexpected dyld_all_image_infos version "
<< all_image_infos.version;
return;
}
size_t expected_size =
process_types::dyld_all_image_infos::ExpectedSizeForVersion(
this, all_image_infos.version);
if (dyld_info.all_image_info_size < expected_size) {
LOG(WARNING) << "small dyld_all_image_infos size "
<< dyld_info.all_image_info_size << " < " << expected_size
<< " for version " << all_image_infos.version;
return;
}
// Note that all_image_infos.infoArrayCount may be 0 if a crash occurred while
// dyld was loading the executable. This can happen if a required dynamic