]> granicus.if.org Git - clang/commit
Bitstream reader: Fix undefined behavior seen after rL364464
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Fri, 5 Jul 2019 20:22:40 +0000 (20:22 +0000)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Fri, 5 Jul 2019 20:22:40 +0000 (20:22 +0000)
commit53d7df893da0ef1ea384934e0b8d3f6ae555cb93
tree3814200a9d641bb98f86ab6b0611bf936c1af927
parent726779ed49bebdb7b68b27fc29c9a5b051a23b53
Bitstream reader: Fix undefined behavior seen after rL364464

Summary:
After rL364464 the following tests started to fail when
running the clang-doc tests with an ubsan instrumented
build of clang-doc:
    Clang Tools :: clang-doc/single-file-public.cpp
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitEnumInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitMethodInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitRecordInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/SerializeTest.emitInfoWithCommentBitcode

We need to check that the read value is in range for being
casted to the llvm::bitc::FixedAbbrevIDs enum, before the
cast in ClangDocBitcodeReader::skipUntilRecordOrBlock.

SerializedDiagnosticReader::skipUntilRecordOrBlock was updated
in the same way.

Reviewers: jfb

Reviewed By: jfb

Subscribers: Bigcheese, vsapsai, bruno, ilya-biryukov, dexonsmith, kadircet, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365239 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Frontend/SerializedDiagnosticReader.cpp