diff options
author | Juergen Ributzka <juergen@apple.com> | 2022-06-13 15:57:51 -0700 |
---|---|---|
committer | Juergen Ributzka <juergen@apple.com> | 2022-06-15 09:28:58 -0700 |
commit | 0557c2d58942f98682323dac75b4a55df5eb8f7b (patch) | |
tree | c2434ed3d727e74d76020ed1e1c82b799f48d80d /llvm/lib/Object/MachOObjectFile.cpp | |
parent | 601ec17d547bf2dc03565b541bae8ec069fbd22b (diff) | |
download | llvm-0557c2d58942f98682323dac75b4a55df5eb8f7b.zip llvm-0557c2d58942f98682323dac75b4a55df5eb8f7b.tar.gz llvm-0557c2d58942f98682323dac75b4a55df5eb8f7b.tar.bz2 |
[llvm] Fix MachO exports trie parsing.
The exports trie parser ordinal validation check doesn't consider the case where
the ordinal can be zero or negative for certain special values that are defined
in BindSpecialDylib. Update the validation to account for that fact and add a
test case.
This fixes rdar://94844233.
Differential Revision: https://reviews.llvm.org/D127806
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index e408062..2f463a1 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -2997,7 +2997,9 @@ void ExportEntry::pushNode(uint64_t offset) { return; } if (O != nullptr) { - if (State.Other > O->getLibraryCount()) { + // Only positive numbers represent library ordinals. Zero and negative + // numbers have special meaning (see BindSpecialDylib). + if ((int64_t)State.Other > 0 && State.Other > O->getLibraryCount()) { *E = malformedError( "bad library ordinal: " + Twine((int)State.Other) + " (max " + Twine((int)O->getLibraryCount()) + |