[llvm] r271032 - Make sure data is available before dereferencing it
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri May 27 11:50:02 PDT 2016
Author: majnemer
Date: Fri May 27 13:50:02 2016
New Revision: 271032
URL: http://llvm.org/viewvc/llvm-project?rev=271032&view=rev
Log:
Make sure data is available before dereferencing it
Modified:
llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp
Modified: llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp?rev=271032&r1=271031&r2=271032&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/RecordSerialization.cpp Fri May 27 13:50:02 2016
@@ -45,6 +45,8 @@ std::error_code llvm::codeview::consume(
}
switch (Short) {
case LF_CHAR:
+ if (Data.size() < 1)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/8,
*reinterpret_cast<const int8_t *>(Data.data()),
/*isSigned=*/true),
@@ -52,6 +54,8 @@ std::error_code llvm::codeview::consume(
Data = Data.drop_front(1);
return std::error_code();
case LF_SHORT:
+ if (Data.size() < 2)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/16,
*reinterpret_cast<const little16_t *>(Data.data()),
/*isSigned=*/true),
@@ -59,6 +63,8 @@ std::error_code llvm::codeview::consume(
Data = Data.drop_front(2);
return std::error_code();
case LF_USHORT:
+ if (Data.size() < 2)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/16,
*reinterpret_cast<const ulittle16_t *>(Data.data()),
/*isSigned=*/false),
@@ -66,6 +72,8 @@ std::error_code llvm::codeview::consume(
Data = Data.drop_front(2);
return std::error_code();
case LF_LONG:
+ if (Data.size() < 4)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/32,
*reinterpret_cast<const little32_t *>(Data.data()),
/*isSigned=*/true),
@@ -73,6 +81,8 @@ std::error_code llvm::codeview::consume(
Data = Data.drop_front(4);
return std::error_code();
case LF_ULONG:
+ if (Data.size() < 4)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/32,
*reinterpret_cast<const ulittle32_t *>(Data.data()),
/*isSigned=*/FalseVal),
@@ -80,6 +90,8 @@ std::error_code llvm::codeview::consume(
Data = Data.drop_front(4);
return std::error_code();
case LF_QUADWORD:
+ if (Data.size() < 8)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/64,
*reinterpret_cast<const little64_t *>(Data.data()),
/*isSigned=*/true),
@@ -87,6 +99,8 @@ std::error_code llvm::codeview::consume(
Data = Data.drop_front(8);
return std::error_code();
case LF_UQUADWORD:
+ if (Data.size() < 8)
+ return std::make_error_code(std::errc::illegal_byte_sequence);
Num = APSInt(APInt(/*numBits=*/64,
*reinterpret_cast<const ulittle64_t *>(Data.data()),
/*isSigned=*/false),
More information about the llvm-commits
mailing list