[libunwind] 9b211a5 - [libunwind] Fix incorrect check for out-of-boundedness

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 12:38:15 PDT 2020


Author: Louis Dionne
Date: 2020-08-11T15:37:57-04:00
New Revision: 9b211a5076310f14081dd257b0cbac6857534bc3

URL: https://github.com/llvm/llvm-project/commit/9b211a5076310f14081dd257b0cbac6857534bc3
DIFF: https://github.com/llvm/llvm-project/commit/9b211a5076310f14081dd257b0cbac6857534bc3.diff

LOG: [libunwind] Fix incorrect check for out-of-boundedness

If the personalityIndex (which is 0-based) is equal to the length of
the personality array, we should error out.

rdar://18013273

Added: 
    

Modified: 
    libunwind/src/UnwindCursor.hpp

Removed: 
    


################################################################################
diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 48902ea0250c..03e21fb87a8d 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1764,7 +1764,7 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc,
                               (__builtin_ctz(UNWIND_PERSONALITY_MASK));
   if (personalityIndex != 0) {
     --personalityIndex; // change 1-based to zero-based index
-    if (personalityIndex > sectionHeader.personalityArrayCount()) {
+    if (personalityIndex >= sectionHeader.personalityArrayCount()) {
       _LIBUNWIND_DEBUG_LOG("found encoding 0x%08X with personality index %d,  "
                             "but personality table has only %d entries",
                             encoding, personalityIndex,


        


More information about the cfe-commits mailing list