Open FiniteReality opened 3 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
This is a good suggestion. Maybe we could see how the runtime or linker (or dumpbin) does it and match that algorithm here. Relevant info: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
Description
Creating a
PEReader
for an invalid file type, such as an ELF can sometimes lead to a situation where thePEReader
thinks the file is valid and it will return garbage data, causing errors to occur downstream.Attached is a zipfile containing an ELF which reproduces the issue, trimmed using
dd
to reduce its filesize while still reproducing the issue.Here's the code I'm running:
Running the same code on a different ELF file throws a
BadImageFormatException
, as expected.Configuration
.NET SDK/Runtime info
``` $ dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42 Runtime Environment: OS Name: debian OS Version: OS Platform: Linux RID: debian-x64 Base Path: /usr/share/dotnet/sdk/5.0.102/ Host (useful for support): Version: 5.0.2 Commit: cb5f173b96 .NET SDKs installed: 3.1.405 [/usr/share/dotnet/sdk] 5.0.102 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App] ```