[llvm] r271496 - [CodeView] Take the StreamRef::readBytes offset into account when validating
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 23:21:44 PDT 2016
Author: majnemer
Date: Thu Jun 2 01:21:44 2016
New Revision: 271496
URL: http://llvm.org/viewvc/llvm-project?rev=271496&view=rev
Log:
[CodeView] Take the StreamRef::readBytes offset into account when validating
We only considered the length of the operation and the length of the
StreamRef without considered what it meant for the offset to be at a
non-zero position.
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h
llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h?rev=271496&r1=271495&r2=271496&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h Thu Jun 2 01:21:44 2016
@@ -29,7 +29,7 @@ public:
Error readBytes(uint32_t Offset, uint32_t Size,
ArrayRef<uint8_t> &Buffer) const override {
- if (Size > Length)
+ if (Size + Offset > Length)
return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
return Stream->readBytes(ViewOffset + Offset, Size, Buffer);
}
Modified: llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp?rev=271496&r1=271495&r2=271496&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp Thu Jun 2 01:21:44 2016
@@ -79,6 +79,8 @@ TEST(MappedBlockStreamTest, ReadBeyondEn
EXPECT_NO_ERROR(R.readStreamRef(SR, 0U));
ArrayRef<uint8_t> Buffer;
EXPECT_ERROR(SR.readBytes(0U, 1U, Buffer));
+ EXPECT_NO_ERROR(R.readStreamRef(SR, 1U));
+ EXPECT_ERROR(SR.readBytes(1U, 1U, Buffer));
}
// Tests that a read which outputs into a full destination buffer works and
More information about the llvm-commits
mailing list