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

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 27 14:44:22 PST 2021


int3 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?
I think it's fairly unlikely that we would have a file with a valid magic number but nothing else. We're not trying to defend against fuzzer inputs anyway, as per https://github.com/llvm/llvm-project/blob/main/lld/docs/NewLLD.rst:

> The current policy is that it is your responsibility to give trustworthy object files. The function is guaranteed to return as long as you do not pass corrupted or malicious object files. A corrupted file could cause a fatal error or SEGV. That being said, you don't need to worry too much about it if you create object files in the usual way and give them to the linker. It is naturally expected to work, or otherwise it's a linker's bug.


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