Improve resiliency of LoadIBCMethodHelper (#23057)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Wed, 6 Mar 2019 18:23:44 +0000 (19:23 +0100)
committerJan Kotas <jkotas@microsoft.com>
Wed, 6 Mar 2019 18:23:44 +0000 (10:23 -0800)
The encoded slot could be bogus and we would end up asserting for this.

src/vm/ceeload.cpp

index 6d1643b..cd46cff 100644 (file)
@@ -7442,6 +7442,11 @@ MethodDesc* Module::LoadIBCMethodHelper(DataImage *image, CORBBTPROF_BLOB_PARAM_
             DWORD slot;
             IfFailThrow(p.GetData(&slot));
 
+            if (slot >= pOwnerMT->GetNumVtableSlots())
+            {
+                COMPlusThrow(kTypeLoadException, IDS_IBC_MISSING_EXTERNAL_METHOD);
+            }
+
             pMethod = pOwnerMT->GetMethodDescForSlot(slot);
         }
         else  // otherwise we use the normal metadata MethodDef token encoding and we handle ibc tokens.