[wpiutil] Fix bug in uleb128 (#3540)

Caused by UB in left shift; identified by ubsan.
This commit is contained in:
Tyler Veness
2021-09-08 16:24:28 -07:00
committed by GitHub
parent 697e2dd330
commit 7810f665f1
2 changed files with 6 additions and 3 deletions

View File

@@ -45,6 +45,8 @@ TEST(LEB128Test, WriteUleb128) {
EXPECT_ULEB128_EQ("\xff\x01", 0xff, 0);
EXPECT_ULEB128_EQ("\x80\x02", 0x100, 0);
EXPECT_ULEB128_EQ("\x81\x02", 0x101, 0);
EXPECT_ULEB128_EQ("\x80\x41", 0x2080, 0);
EXPECT_ULEB128_EQ("\x80\xc1\x80\x80\x10", 0x100002080, 0);
#undef EXPECT_ULEB128_EQ
}
@@ -70,7 +72,8 @@ TEST(LEB128Test, ReadUleb128) {
EXPECT_READ_ULEB128_EQ(0xffu, "\xff\x01");
EXPECT_READ_ULEB128_EQ(0x100u, "\x80\x02");
EXPECT_READ_ULEB128_EQ(0x101u, "\x81\x02");
EXPECT_READ_ULEB128_EQ(8320u, "\x80\xc1\x80\x80\x10");
EXPECT_READ_ULEB128_EQ(0x2080u, "\x80\x41");
EXPECT_READ_ULEB128_EQ(0x100002080u, "\x80\xc1\x80\x80\x10");
#undef EXPECT_READ_ULEB128_EQ
}