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 <ivanpe@chromium.org>
This commit is contained in:
Adam Duke 2022-04-08 10:47:18 -04:00 committed by Ivan Penkov
parent 8b68c72a3f
commit c85eb4a59b

View file

@ -413,6 +413,13 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& 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";