[custom_attrs] Add (some) bounds checking to create_custom_attr
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 2 Aug 2017 21:32:23 +0000 (17:32 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Thu, 3 Aug 2017 17:32:25 +0000 (13:32 -0400)
commitfab01c2cff4ba85c02fece5bded329dbc80351a4
treebffb4c408f234f0f46e00ab4ff660c1b3648d657
parent45d9cc1b5a7643b975608b680ed7dbe193543801
[custom_attrs] Add (some) bounds checking to create_custom_attr

In principle, mono_verifier_verify_cattr_content should prevent malformed custom
attribute blobs from being passed in here.

In practice:

1. The verifier is not on by default

2. System.Reflection.Emit allows an arbitrary byte[] to be passed in which
   means that code like this can cause mono to read past the end of the array.

   ```
   // "1 1-byte constructor argument and then 65280 named properties follow"
   assembly.SetCustomAttribute(constructor, new byte[] { 1, 0, 1, 0x00, 0xFF });
   var attributes = assembly.GetCustomAttributes(true);
   ```
mono/metadata/custom-attrs.c