Fix InternalsVisibleTo when it references an assembly with some DebuggableAttribute...
authorKoundinya Veluri <kouvel@microsoft.com>
Mon, 3 Apr 2017 23:35:47 +0000 (16:35 -0700)
committerGitHub <noreply@github.com>
Mon, 3 Apr 2017 23:35:47 +0000 (16:35 -0700)
Fixes #3541
- Mask out the DebuggableAttribute bits from when comparing assembly spec flags for matching an InternalsVisibleTo reference to an assembly

src/inc/corhdr.h
src/md/compiler/mdvalidator.cpp
src/vm/baseassemblyspec.cpp

index c194def07f790b5190bdb58333d5a77074e4a37a..4b757421cb94cf2f5d968eb9e503b5e942c29b21 100644 (file)
@@ -751,6 +751,7 @@ typedef enum CorAssemblyFlags
 
     afEnableJITcompileTracking   =  0x8000, // From "DebuggableAttribute".
     afDisableJITcompileOptimizer =  0x4000, // From "DebuggableAttribute".
+    afDebuggableAttributeMask    =  0xc000,
 
     afRetargetable          =   0x0100,     // The assembly can be retargeted (at runtime) to an
                                             //  assembly from a different publisher.
index 0b86738cfb99f99c5061f9261ca42e3f63c85f72..ce6c14e4688b0b7d01610f955c80fcb453f393a0 100644 (file)
@@ -5207,7 +5207,7 @@ HRESULT RegMeta::ValidateAssembly(RID rid)
     dwFlags = (CorAssemblyFlags) pMiniMd->getFlagsOfAssembly(pRecord);
 
     // Validate the flags 
-    invalidAssemblyFlags = dwFlags & (~(afPublicKey | afRetargetable | afPA_FullMask | afEnableJITcompileTracking | afDisableJITcompileOptimizer | afContentType_Mask));
+    invalidAssemblyFlags = dwFlags & (~(afPublicKey | afRetargetable | afPA_FullMask | afDebuggableAttributeMask | afContentType_Mask));
 
     // Validate we only set a legal processor architecture flags
     // The processor architecture flags were introduced in CLR v2.0.
index fdaa981523d1abd3425508a53e01643c43b47d48..4d6ba26e40b8748164dd8e8524a44d29edce90db 100644 (file)
@@ -266,9 +266,9 @@ BOOL BaseAssemblySpec::CompareRefToDef(const BaseAssemblySpec *pRef, const BaseA
     }
 
     //
-    // flags are non-optional, except processor architecture and content type
+    // flags are non-optional, except processor architecture, content type, and debuggable attribute bits
     //
-    DWORD dwFlagsMask = ~(afPA_FullMask | afContentType_Mask);
+    DWORD dwFlagsMask = ~(afPA_FullMask | afContentType_Mask | afDebuggableAttributeMask);
     if ((pRef->m_dwFlags & dwFlagsMask) != (pDef->m_dwFlags & dwFlagsMask))
         return FALSE;