summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-05-19 00:34:17 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-05-19 00:34:17 +0000
commitf3fa99c48e2a69b2df4a06249b987919b744acd9 (patch)
treeb1a30e4096cf48a9c78f0ea70962498e9541f8d9 /llvm/lib/Bitcode/Reader/BitstreamReader.cpp
parent887fdfb7592fd5b14a2d7fb50ee56f00d6ffeb58 (diff)
downloadbcm5719-llvm-f3fa99c48e2a69b2df4a06249b987919b744acd9.tar.gz
bcm5719-llvm-f3fa99c48e2a69b2df4a06249b987919b744acd9.zip
[BitcodeReader] It's a malformed block if CodeLenWidth is too big
Bug found with AFL fuzz. llvm-svn: 237646
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitstreamReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitstreamReader.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
index dff6d181486..450bbbc4558 100644
--- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
@@ -39,6 +39,10 @@ bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
// Get the codesize of this block.
CurCodeSize = ReadVBR(bitc::CodeLenWidth);
+ // We can't read more than MaxChunkSize at a time
+ if (CurCodeSize > MaxChunkSize)
+ return true;
+
SkipToFourByteBoundary();
unsigned NumWords = Read(bitc::BlockSizeWidth);
if (NumWordsP) *NumWordsP = NumWords;
OpenPOWER on IntegriCloud