diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2019-03-22 14:53:31 +0100 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2019-03-25 18:04:24 +0100 |
commit | 7a928d80d2c6eb227b70144a0a8018f3ec67066b (patch) | |
tree | c421e299123786c53963da682dfe2c1f8a503fb9 /src/vm/assemblynative.cpp | |
parent | e6c49f73eac2413fdc7a1024fc0f1585e39db026 (diff) | |
download | coreclr-7a928d80d2c6eb227b70144a0a8018f3ec67066b.tar.gz coreclr-7a928d80d2c6eb227b70144a0a8018f3ec67066b.tar.bz2 coreclr-7a928d80d2c6eb227b70144a0a8018f3ec67066b.zip |
Disable loading IJW assemblies into collectible ALC
Diffstat (limited to 'src/vm/assemblynative.cpp')
-rw-r--r-- | src/vm/assemblynative.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp index ed2ce660e7..6cbb8afc17 100644 --- a/src/vm/assemblynative.cpp +++ b/src/vm/assemblynative.cpp @@ -248,6 +248,13 @@ void QCALLTYPE AssemblyNative::LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext // Need to verify that this is a valid CLR assembly. if (!pILImage->CheckILFormat()) ThrowHR(COR_E_BADIMAGEFORMAT, BFA_BAD_IL); + + LoaderAllocator* pLoaderAllocator = NULL; + if (SUCCEEDED(pBinderContext->GetLoaderAllocator((LPVOID*)&pLoaderAllocator)) && pLoaderAllocator->IsCollectible() && !pILImage->IsILOnly()) + { + // Loading IJW assemblies into a collectible AssemblyLoadContext is not allowed + ThrowHR(COR_E_BADIMAGEFORMAT, BFA_IJW_IN_COLLECTIBLE_ALC); + } } // Form the PEImage for the NI assembly, if specified @@ -327,7 +334,14 @@ void QCALLTYPE AssemblyNative::LoadFromStream(INT_PTR ptrNativeAssemblyLoadConte // Get the binder context in which the assembly will be loaded ICLRPrivBinder *pBinderContext = reinterpret_cast<ICLRPrivBinder*>(ptrNativeAssemblyLoadContext); - + + LoaderAllocator* pLoaderAllocator = NULL; + if (SUCCEEDED(pBinderContext->GetLoaderAllocator((LPVOID*)&pLoaderAllocator)) && pLoaderAllocator->IsCollectible() && !pILImage->IsILOnly()) + { + // Loading IJW assemblies into a collectible AssemblyLoadContext is not allowed + ThrowHR(COR_E_BADIMAGEFORMAT, BFA_IJW_IN_COLLECTIBLE_ALC); + } + // Pass the stream based assembly as IL and NI in an attempt to bind and load it Assembly* pLoadedAssembly = AssemblyNative::LoadFromPEImage(pBinderContext, pILImage, NULL); { |