This is an archive of the discontinued LLVM Phabricator instance.

Bitstream reader: Fix undefined behavior seen after rL364464
ClosedPublic

Authored by bjope on Jul 5 2019, 1:08 PM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

bjope created this revision.Jul 5 2019, 1:08 PM
jfb accepted this revision.Jul 5 2019, 1:09 PM
jfb added subscribers: bruno, vsapsai.
jfb added a subscriber: Bigcheese.

Thanks for catching this!

This revision is now accepted and ready to land.Jul 5 2019, 1:11 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2019, 1:25 PM