From 1d75af9bf5918fa1c365a4ac696f038e6028a30b Mon Sep 17 00:00:00 2001 From: Justin Cohen Date: Tue, 10 Mar 2020 16:16:21 -0400 Subject: [PATCH] Fix bad iOS module casting. Change-Id: I0f8dcd867c56c4b1476c23d280e08448d2e90795 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2097177 Reviewed-by: Mark Mentovai Commit-Queue: Justin Cohen --- snapshot/ios/module_snapshot_ios.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/snapshot/ios/module_snapshot_ios.cc b/snapshot/ios/module_snapshot_ios.cc index 824ad8a5..8b251eb9 100644 --- a/snapshot/ios/module_snapshot_ios.cc +++ b/snapshot/ios/module_snapshot_ios.cc @@ -87,25 +87,26 @@ bool ModuleSnapshotIOS::FinishInitialization() { cmd_index <= header->ncmds && cumulative_cmd_size < header->sizeofcmds; ++cmd_index, cumulative_cmd_size += command->cmdsize) { if (command->cmd == LC_SEGMENT_64) { - segment_command_64* segment = - reinterpret_cast(&command); + const segment_command_64* segment = + reinterpret_cast(command); if (strcmp(segment->segname, SEG_TEXT) == 0) { size_ = segment->vmsize; } } else if (command->cmd == LC_ID_DYLIB) { - dylib_command* dylib = reinterpret_cast(&command); + const dylib_command* dylib = + reinterpret_cast(command); dylib_version_ = dylib->dylib.current_version; } else if (command->cmd == LC_SOURCE_VERSION) { - source_version_command* source_version = - reinterpret_cast(&command); + const source_version_command* source_version = + reinterpret_cast(command); source_version_ = source_version->version; } else if (command->cmd == LC_UUID) { - uuid_command* uuid = reinterpret_cast(&command); + const uuid_command* uuid = reinterpret_cast(command); uuid_.InitializeFromBytes(uuid->uuid); } command = reinterpret_cast( - reinterpret_cast(command + command->cmdsize)); + reinterpret_cast(command) + command->cmdsize); // TODO(justincohen): Warn-able things: // - Bad Mach-O magic (and give up trying to process the module)