[InstrProf] Tighten a check for malformed data records in raw profiles
authorVedant Kumar <vsk@apple.com>
Tue, 3 Sep 2019 22:23:14 +0000 (22:23 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 3 Sep 2019 22:23:14 +0000 (22:23 +0000)
commit95fb23ab37e5e348788bb34623ebdc1e583e1ec8
treeff6f0bd6c6a2813e32036607cd579ea1bc6c9783
parenta6fcadd0f037df5e5bdc8d44a1769bf4bc9d22cd
[InstrProf] Tighten a check for malformed data records in raw profiles

The check needs to validate a counter offset before performing pointer
arithmetic with the (potentially corrupt) offset.

Found by UBSan's pointer overflow check.

rdar://54843625

Differential Revision: https://reviews.llvm.org/D66979

llvm-svn: 370826
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/test/tools/llvm-profdata/Inputs/malformed-ptr-to-counter-array.profraw [new file with mode: 0644]
llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test [new file with mode: 0644]