[llvm] r271791 - [CodeView] Validate the vftable offset

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 4 08:40:30 PDT 2016


Author: majnemer
Date: Sat Jun  4 10:40:29 2016
New Revision: 271791

URL: http://llvm.org/viewvc/llvm-project?rev=271791&view=rev
Log:
[CodeView] Validate the vftable offset

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

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=271791&r1=271790&r2=271791&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Sat Jun  4 10:40:29 2016
@@ -1061,8 +1061,12 @@ public:
     MethodOptions Options = L->Attrs.getFlags();
     MethodKind MethKind = L->Attrs.getMethodKind();
     MemberAccess Access = L->Attrs.getAccess();
-    return OneMethodRecord(L->Type, MethKind, Options, Access, VFTableOffset,
+    OneMethodRecord Method(L->Type, MethKind, Options, Access, VFTableOffset,
                            Name);
+    // Validate the vftable offset.
+    if (Method.isIntroducingVirtual() && Method.getVFTableOffset() < 0)
+      return std::make_error_code(std::errc::illegal_byte_sequence);
+    return Method;
   }
 
   TypeIndex getType() const { return Type; }
@@ -1122,6 +1126,11 @@ public:
 
       Methods.emplace_back(L->Type, MethKind, Options, Access, VFTableOffset,
                            StringRef());
+
+      // Validate the vftable offset.
+      auto &Method = Methods.back();
+      if (Method.isIntroducingVirtual() && Method.getVFTableOffset() < 0)
+        return std::make_error_code(std::errc::illegal_byte_sequence);
     }
     return MethodOverloadListRecord(Methods);
   }




More information about the llvm-commits mailing list