summaryrefslogtreecommitdiff
path: root/include/llvm/Bitcode
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-06-25 17:08:50 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-06-25 17:08:50 +0000
commit3e64427cb3381b6fdb498bcdbf2abef0bf22e0f0 (patch)
treee080b3efb1b90dc7cf80db16c311f5973042ed33 /include/llvm/Bitcode
parent644eb9befc4334f408cb6bed90ec5ed1a30f32a6 (diff)
downloadllvm-3e64427cb3381b6fdb498bcdbf2abef0bf22e0f0.tar.gz
llvm-3e64427cb3381b6fdb498bcdbf2abef0bf22e0f0.tar.bz2
llvm-3e64427cb3381b6fdb498bcdbf2abef0bf22e0f0.tar.xz
Enhance the sanity check for block sizes; check that the resulting pointer is
pointing to the range [first character, last character] instead of just not after the last character. Patch by Yan Ivnitskiy! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode')
-rw-r--r--include/llvm/Bitcode/BitstreamReader.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h
index 779ef5fa2d..0ca3ad1561 100644
--- a/include/llvm/Bitcode/BitstreamReader.h
+++ b/include/llvm/Bitcode/BitstreamReader.h
@@ -375,10 +375,12 @@ public:
// Check that the block wasn't partially defined, and that the offset isn't
// bogus.
- if (AtEndOfStream() || NextChar+NumWords*4 > BitStream->getLastChar())
+ const unsigned char *const SkipTo = NextChar + NumWords*4;
+ if (AtEndOfStream() || SkipTo > BitStream->getLastChar() ||
+ SkipTo < BitStream->getFirstChar())
return true;
- NextChar += NumWords*4;
+ NextChar = SkipTo;
return false;
}