apple / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.1k stars 320 forks source link

🍒[release/6.0][llvm][MachO] Fix integer truncation in rebase/bind parsing (#89337) #8832

Closed zixu-w closed 1 month ago

zixu-w commented 1 month ago

Count and Skip should use uint64_t as they are encoded/decoded using 64-bit ULEB128.

In *_OPCODE_DO_*_ULEB_TIMES_SKIPPING_ULEB, Skip could be encoded as a two's complement for moving SegmentOffset backwards. Having a 32-bit Skip truncates the encoded value and leads to a malformed AdvanceAmount and invalid SegmentOffset that extends past valid sections.

(cherry picked from commit b910bebc300dafb30569cecc3017b446ea8eafa0)

zixu-w commented 1 month ago

@swift-ci please test

zixu-w commented 1 month ago

Hi @fredriss could you help merge this PR? Thanks!