-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible ArgumentOutOfRangeException when there are 65535 params in metadata table #913
Comments
That's a good catch, thank you :) |
The magic actually happens here in uint endRid = !hasNext || (nextListRid == 0 && tableSourceRid + 1 == tableSource.Rows && tableDest.Rows == 0xFFFF) ? lastRid : nextListRid; |
Thanks for pointing out. In my situation, |
This was referenced Jun 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cecil/Mono.Cecil/AssemblyReader.cs
Lines 979 to 1003 in ba9c6c7
(Sorry but I'm unable to provide a sample dll.)
We have a big dll which exactly has 65535 parameters in metadata table.
When processing it using cecil, it throw exception like this:
After some debugging I managed to locate the problem:
cecil/Mono.Cecil/AssemblyReader.cs
Line 995 in ba9c6c7
When it's trying to read the 65535th (the last) param (it is used in a compiler-generated anonymous method), and
image.GetTableIndexSize
returns 2 (entry < 65536),ReadTableIndex
returns 0,next_index = 0
.cecil/Mono.Cecil/AssemblyReader.cs
Line 1000 in ba9c6c7
list.Length = next_index - start = 0u - 65535u = 4294901761
💥On the other hand, dnlib already handled this problem, so it still works for our dll:
https://github.com/0xd4d/dnlib/blob/97e07a8f1ea0ccbf31231dad0f7cb093805b8eee/src/DotNet/MD/CompressedMetadata.cs#L143-L157
The magic happens here:
The text was updated successfully, but these errors were encountered: