-
-
Notifications
You must be signed in to change notification settings - Fork 636
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, |
Hi! @jbevain we have a symmetric issue at Unity, but mono - Mono.Cecil generates an assembly with exactly 65535 fields and loading it in mono results in the crash due to very similar table row usage logic. Are there any reasons that #914 was not merged yet and would be feasible to use |
wrt my last comment - I checked what happens if we use large indices when table size is 65535 and it doesn't work as no reader can then read assembly properly. According to the standard large indices are only used for row count 2^16 and above |
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: