llvm.org GIT mirror llvm / 4ef54c3
[Support] Fix the overflow bug in ULEB128 decoding. Differential Revision: http://reviews.llvm.org/D5029 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216268 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Lorenz 6 years ago
2 changed file(s) with 2 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
8181 uint64_t Value = 0;
8282 unsigned Shift = 0;
8383 do {
84 Value += (*p & 0x7f) << Shift;
84 Value += uint64_t(*p & 0x7f) << Shift;
8585 Shift += 7;
8686 } while (*p++ >= 128);
8787 if (n)
105105 EXPECT_DECODE_ULEB128_EQ(0xffu, "\xff\x01");
106106 EXPECT_DECODE_ULEB128_EQ(0x100u, "\x80\x02");
107107 EXPECT_DECODE_ULEB128_EQ(0x101u, "\x81\x02");
108 EXPECT_DECODE_ULEB128_EQ(4294975616ULL, "\x80\xc1\x80\x80\x10");
108109
109110 // Decode ULEB128 with extra padding bytes
110111 EXPECT_DECODE_ULEB128_EQ(0u, "\x80\x00");