[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
Tue Mar 2 01:40:24 PST 2021


gkm added a comment.

In D97610#2595963 <https://reviews.llvm.org/D97610#2595963>, @thakis wrote:

> a) I think this breaks --reproduce=repro.tar for `-order_file` since that previously called `readFile()` which added to the repro tar, but now `readRawFile()` doesn't. (Looks like -sectcreate has the same problem likely.)

`-sectcreate` is subtle. It should be an opaque object immune to meddling, but as-is, if it happens to be `MachO::FAT_MAGIC` its arch component will be extracted. I am not going to fret about that until it proves troublesome.

> b) What's the motivation for this change? lld assumes that inputs are produced by a compiler or similar, and are generally valid. What problem is this solving?

The immediate motive was to fix an ASAN overflow when checking magic# of an empty buffer. My solution was an ill-conceived refactor with insufficient understanding. Apologies. This reverts the refactor and adds a modest one-line check that the file buffer is long-enough for a magic number: https://reviews.llvm.org/D97757


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