[PATCH] D97610: [lld-macho] check minimum header length when opening linkable input files

Greg McGary via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 27 14:25:27 PST 2021


gkm marked an inline comment as done.
gkm added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:124
+  if (mbref.getBufferSize() < sizeof(uint32_t)) {
+    error("file is too small to contain a magic number: " + path);
+    return None;
----------------
tschuett wrote:
> What are you going to do with. e.g. 4, 5, or 6 bytes files. It only has the magic numbers, but there is no real header?
Those will be validated downstream, based on magic number. If the magic number doesn't match anything we handle, then it will be rejected as such. If the magic number is valid, then the code for that file type will check that the header & contents are complete & consistent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97610/new/

https://reviews.llvm.org/D97610



More information about the llvm-commits mailing list