[llvm] r271031 - Avoid overflow when computing the size of an array

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 11:50:01 PDT 2016


Author: majnemer
Date: Fri May 27 13:50:00 2016
New Revision: 271031

URL: http://llvm.org/viewvc/llvm-project?rev=271031&view=rev
Log:
Avoid overflow when computing the size of an array

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h?rev=271031&r1=271030&r2=271031&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h Fri May 27 13:50:00 2016
@@ -102,6 +102,10 @@ template <typename T, typename U> struct
       return std::error_code();
 
     uint32_t Size = sizeof(T) * N;
+
+    if (Size / sizeof(T) != N)
+      return std::make_error_code(std::errc::illegal_byte_sequence);
+
     if (Data.size() < Size)
       return std::make_error_code(std::errc::illegal_byte_sequence);
 




More information about the llvm-commits mailing list