Test case for security issue
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 25 Nov 2010 22:01:56 +0000 (17:01 -0500)
committerSebastien Pouliot <sebastien@ximian.com>
Wed, 15 Dec 2010 16:06:41 +0000 (11:06 -0500)
mcs/class/corlib/Test/System.Reflection/MethodBaseTest.cs

index 67c4d1e91ab69a55ac3a9b6f987fea966335abbb..fcefa0403d70738e804d4bbdbc41a99beb280276 100644 (file)
@@ -326,5 +326,28 @@ namespace MonoTests.System.Reflection
                        } catch (ArgumentException) {
                        }
                }
+
+               // test case adapted from http://www.chrishowie.com/2010/11/24/mutable-strings-in-mono/
+               public class FakeString {
+                       public int length;
+                       public char start_char;
+               }
+
+               private static FakeString UnsafeConversion<T> (T thing) where T : FakeString
+               {
+                       return thing;
+               }
+
+               [Test]
+               public void MutableString ()
+               {
+                       var m = typeof (MethodBaseTest).GetMethod ("UnsafeConversion", BindingFlags.NonPublic | BindingFlags.Static);
+                       try {
+                               var m2 = m.MakeGenericMethod (typeof (string));
+                               Assert.Fail ("MakeGenericMethod");
+                       }
+                       catch (ArgumentException) {
+                       }
+               }
        }
 }