Skip to content

Commit 6f0ce34

Browse files
authored
Fix check for host_runtime_contract having external_assembly_probe (#118792)
We should check the size of the contract to determine if it can have `external_assembly_probe`. In practice, we probably haven't hit this since `hostpolicy` ships next to `coreclr` - but any sort of patching such that `coreclr` is newer than `hostpolicy` could result in incorrectly determining that `external_assembly_probe` is set.
1 parent 7ba3876 commit 6f0ce34

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/coreclr/vm/hostinformation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ bool HostInformation::GetProperty(_In_z_ const char* name, SString& value)
4545

4646
bool HostInformation::HasExternalProbe()
4747
{
48-
return s_hostContract.external_assembly_probe != nullptr;
48+
size_t requiredSize = offsetof(host_runtime_contract, external_assembly_probe) + sizeof(s_hostContract.external_assembly_probe);
49+
return s_hostContract.size >= requiredSize && s_hostContract.external_assembly_probe != nullptr;
4950
}
5051

5152
bool HostInformation::ExternalAssemblyProbe(_In_ const SString& path, _Out_ void** data, _Out_ int64_t* size)

0 commit comments

Comments
 (0)