[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,7 +45,7 @@ uint64_t ReadUleb128(const char* addr, uint64_t* ret) {
addr++;
count++;
result |= (byte & 0x7f) << shift;
result |= (byte & 0x7fULL) << shift;
shift += 7;
if (!(byte & 0x80)) {
@@ -69,7 +69,7 @@ bool ReadUleb128(raw_istream& is, uint64_t* ret) {
return false;
}
result |= (byte & 0x7f) << shift;
result |= (byte & 0x7fULL) << shift;
shift += 7;
if (!(byte & 0x80)) {