[PATCH] Report fatal errors instead of segfaulting/asserting on a few invalid accesses while reading MachO files.
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Tue Jan 13 09:17:18 PST 2015
Optional bonus (can be another patch): include more information in the errors: Section index is XXX, but there are only YYY sections.
================
Comment at: lib/Object/MachOObjectFile.cpp:45
@@ +44,3 @@
+ if (P < O->getData().begin() || P + sizeof(T) > O->getData().end())
+ report_fatal_error("Malformed MachO file.");
+
----------------
There are no tests for this one. Please add one or convert this to an assert.
================
Comment at: lib/Object/MachOObjectFile.cpp:60
@@ -54,1 +59,3 @@
MachO::segment_command_64 S = O->getSegment64LoadCommand(L);
+ if (S.nsects > std::numeric_limits<uint32_t>::max() / SectionSize ||
+ S.nsects * SectionSize > L.C.cmdsize - sizeof(S))
----------------
Nit. maybe avoid this bit of duplicated with a small helper template function that takes a MachO::segment_command_64 or a MachO::segment_command?
http://reviews.llvm.org/D6945
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list