[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:06:40 PDT 2020
rprichard created this revision.
Herald added projects: LLVM, libunwind.
Herald added subscribers: libcxx-commits, llvm-commits.
Herald added a reviewer: libunwind.
Previously, for large-enough values, getSLEB128 would attempt to shift
a signed int in the range [0..0x7f] by 28, 35, 42... bits, which is
undefined behavior and likely to fail.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83742
Files:
libunwind/src/AddressSpace.hpp
Index: libunwind/src/AddressSpace.hpp
===================================================================
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -290,7 +290,7 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83742.277661.patch
Type: text/x-patch
Size: 453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200714/dc59bc06/attachment-0001.bin>
More information about the libcxx-commits
mailing list