Fix reading of undefined NativeType values in old Cecil
commitcd08c69f0a23569bf9abb58e3f1c06416874c99f
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 9 Apr 2019 14:09:54 +0000 (9 16:09 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 9 Apr 2019 15:27:43 +0000 (9 17:27 +0200)
treeefc01319e50db1df87b940ae478cc90c3aa30f2d
parentaf5b50b1348f8bb6e2d80143cdc0bc437d8a1924
Fix reading of undefined NativeType values in old Cecil

cil-strip crashed when processing this method: https://github.com/mono/corefx/blob/f54e64b341a7b114c3502e197b46670cacb28639/src/Microsoft.CSharp/tests/DefaultParameterTests.cs#L88

It uses `MarshalAs((UnmanagedType)2000)`, i.e. an undefined value for the
native type. The old Cecil embedded in cil-strip tried to read more than one
byte which blows up in this case. Upstream Cecil just reads a single byte:
https://github.com/jbevain/cecil/blob/1b79b96d29f1e8e9ba832191b1b42ea9cb750d20/Mono.Cecil/AssemblyReader.cs#L3700-L3703

Fixes https://github.com/mono/mono/issues/13639
mcs/tools/cil-strip/Mono.Cecil.Signatures/SignatureReader.cs