Skip to content

Commit

Permalink
Add check for byte code table size (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKlatecki authored Oct 29, 2024
1 parent 6ee2961 commit aba8387
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions MetadataProcessor.Shared/Tables/nanoByteCodeTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public ushort GetMethodId(

var byteCode = CreateByteCode(method);

// sanity check for RVA overflow
if (_lastAvailableRva + byteCode.Length > ushort.MaxValue)
{
throw new InvalidOperationException($"Byte code table overflow in assembly '{_context.AssemblyDefinition.Name}'. It's impossible to compile such a large assembly.");
}

_methods.Add(method);
_lastAvailableRva += (ushort)byteCode.Length;

Expand Down Expand Up @@ -161,3 +167,4 @@ private byte[] CreateByteCode(
}
}
}

0 comments on commit aba8387

Please sign in to comment.