From 57d813c8da1808e624995d130a5554cdd17116ff Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Tue, 13 Dec 2016 22:49:14 +0000 Subject: [PATCH] [libFuzzer] fix an UB (invalid shift) spotted by ubsan. The code worked fine by luck, because the way shifts actually work on clang+x86 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289607 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Fuzzer/FuzzerTracePC.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Fuzzer/FuzzerTracePC.h b/lib/Fuzzer/FuzzerTracePC.h index df037390c2a..e3f6f10a36f 100644 --- a/lib/Fuzzer/FuzzerTracePC.h +++ b/lib/Fuzzer/FuzzerTracePC.h @@ -126,7 +126,7 @@ size_t TracePC::CollectFeatures(Callback CB) { uint64_t Bundle = *reinterpret_cast(&Counters[Idx]); if (!Bundle) continue; for (size_t i = Idx; i < Idx + Step; i++) { - uint8_t Counter = (Bundle >> (i * 8)) & 0xff; + uint8_t Counter = (Bundle >> ((i - Idx) * 8)) & 0xff; if (!Counter) continue; Counters[i] = 0; unsigned Bit = 0; -- 2.50.0