Registry Mirror
Skip to content

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Problem

TransformArrayInitializers.HandleSimpleArrayInitializer multiplies the array dimensions to size the list it collects elements into:

int length = arrayLength.Aggregate(1, (t, l) => t * l);

The dimensions come from the input assembly and need not multiply within int range. ICSharpCode.Decompiler is built with CheckForOverflowUnderflow, so this throws instead of wrapping, and the OverflowException aborts decompilation of the whole member:

System.OverflowException: Arithmetic operation resulted in an overflow.
   at ...TransformArrayInitializers.<>c.<HandleSimpleArrayInitializer>b__22_0(Int32 t, Int32 l)
   at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](...)
   at ...TransformArrayInitializers.HandleSimpleArrayInitializer(...)
   at ...TransformArrayInitializers.DoTransformMultiDim(...)

Fix

The product is used only as the initial capacity of valuesList and has no bearing on the result, so it can saturate instead of overflowing.

Testing

A new int[65536, 65536] case added to the MultidimensionalArray fixture, whose dimensions multiply to more than int.MaxValue. It fails without the fix with the stack above.

Full ILSpy.XPlat.slnf suite: 3366 tests, 0 failed, 44 skipped (Windows-only).

How it was found

Fuzzing the nuget.org catalog through the decompiler; the original hit was an obfuscated assembly.


Written by an AI agent (Claude) on Siegfried's behalf.

…izer

HandleSimpleArrayInitializer multiplies the array dimensions to size the list
it collects elements into. The dimensions come from the input assembly and
need not multiply within int range, and ICSharpCode.Decompiler is built with
CheckForOverflowUnderflow, so an implausible pair of dimensions aborted
decompilation of the whole member. The product is only a capacity hint, so it
can saturate.

Found by fuzzing nuget.org; reproduces on obfuscated assemblies.

Assisted-by: Claude:claude-opus-5[1m]:Claude Code
@siegfriedpammer
siegfriedpammer force-pushed the fix-array-dimension-overflow branch from 799ee04 to 2f28890 Compare August 7, 2026 05:53
@siegfriedpammer
siegfriedpammer merged commit 6fe6e06 into master Aug 7, 2026
15 checks passed
@siegfriedpammer
siegfriedpammer deleted the fix-array-dimension-overflow branch August 7, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant