[libcxx-commits] [PATCH] D83742: [libunwind] Fix getSLEB128 on large values

Ryan Prichard via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 13 22:19:55 PDT 2020


rprichard updated this revision to Diff 277668.
rprichard added a comment.

The shift for negative numbers is also broken.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83742/new/

https://reviews.llvm.org/D83742

Files:
  libunwind/src/AddressSpace.hpp


Index: libunwind/src/AddressSpace.hpp
===================================================================
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -290,11 +290,11 @@
     if (p == pend)
       _LIBUNWIND_ABORT("truncated sleb128 expression");
     byte = *p++;
-    result |= ((byte & 0x7f) << bit);
+    result |= (uint64_t)(byte & 0x7f) << bit;
     bit += 7;
   } while (byte & 0x80);
   // sign extend negative numbers
-  if ((byte & 0x40) != 0)
+  if ((byte & 0x40) != 0 && bit < 64)
     result |= (-1ULL) << bit;
   addr = (pint_t) p;
   return result;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83742.277668.patch
Type: text/x-patch
Size: 592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200714/23e3a98f/attachment.bin>


More information about the libcxx-commits mailing list