OSDN Git Service

Tighten some of the name map checks further
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 28 May 2016 18:03:37 +0000 (18:03 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 28 May 2016 18:03:37 +0000 (18:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271130 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/PDB/Raw/NameMap.cpp

index ad60a44..62a86da 100644 (file)
@@ -50,7 +50,11 @@ Error NameMap::load(codeview::StreamReader &Stream) {
                       make_error<RawError>(raw_error_code::corrupt_file,
                                            "Expected name map max strings"));
 
-  const uint32_t MaxNumberOfWords = UINT32_MAX / sizeof(uint32_t);
+  if (MaxNumberOfStrings > (UINT32_MAX / sizeof(uint32_t)))
+    return make_error<RawError>(raw_error_code::corrupt_file,
+                                "Implausible number of strings");
+
+  const uint32_t MaxNumberOfWords = UINT32_MAX / (sizeof(uint32_t) * 8);
 
   // This appears to be a hash table which uses bitfields to determine whether
   // or not a bucket is 'present'.