This reverts diff D97610 (commit 0223ab035c199e537a0040857ba147ced87fd533) and adds a one-line fix to verify that a MemoryBufferRef has sufficient length before reading a 4-byte magic number.
Details
Details
- Reviewers
int3 thakis - Group Reviewers
Restricted Project - Commits
- rG4af1522a855e: [lld-macho] Rework length check when opening input files
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Unit Tests
Event Timeline
lld/MachO/InputFiles.cpp | ||
---|---|---|
109–110 | This is the new guard for adequate buffer size before reading the magic# |
Comment Actions
Thanks, much nicer :)
It's important to keep in mind that 99.9% of lld invocations (on non-Win) are through clang, and clang will never pass /dev/null as an input file (unless you try really hard, with -Wl,/dev/null. So I don't even think crashing on this input would be all that terrible. But if it can be prevented with a simple one-line fix, then fixing is fine too I suppose.
lld/test/MachO/rename.s | ||
---|---|---|
17 | Looks like on Windows /dev/null is replaced with a temp file: ld64.lld: error: C:\Users\ContainerAdministrator\AppData\Local\Temp\lit_tmp_xrue9d5c\tmprj2ybz87: unhandled file type So probably use {{.*}} as file name here and below, |
This is the new guard for adequate buffer size before reading the magic#