From c85eb4a59b618f3beaad5445ceb1f865ffa8efdf Mon Sep 17 00:00:00 2001 From: Adam Duke Date: Fri, 8 Apr 2022 10:47:18 -0400 Subject: [PATCH] avoid dump_syms crashing if selected arch is not found https://crrev.com/c/3327644 introduced the ability for dump_syms to operate on in memory data, which has the consequence of not going through the same input validation as the dump_syms cli tool. In certain cases, it is possible that architecture info can't be reliably determined, e.g. new architectures that breakpad is unware of. In that case, dump_syms should avoid crashing when calling ReadSymbolData and return false instead. Change-Id: Ie9acdf811300084f1d5916f4778754f8abca10e0 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3572251 Reviewed-by: Ivan Penkov --- src/common/mac/dump_syms.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/mac/dump_syms.cc b/src/common/mac/dump_syms.cc index b1cb1a30..c62caed2 100644 --- a/src/common/mac/dump_syms.cc +++ b/src/common/mac/dump_syms.cc @@ -413,6 +413,13 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr& module) { google_breakpad::BreakpadGetArchInfoFromCpuType( selected_object_file_->cputype, selected_object_file_->cpusubtype); + // In certain cases, it is possible that architecture info can't be reliably + // determined, e.g. new architectures that breakpad is unware of. In that + // case, avoid crashing and return false instead. + if (selected_arch_info == NULL) { + return false; + } + const char* selected_arch_name = selected_arch_info->name; if (strcmp(selected_arch_name, "i386") == 0) selected_arch_name = "x86";