[Mono-bugs] [Bug 48752][Blo] New - corrupted indexer value causes exception

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 23 Sep 2003 04:22:20 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mass@akuma.org.

http://bugzilla.ximian.com/show_bug.cgi?id=48752

--- shadow/48752	2003-09-23 04:22:20.000000000 -0400
+++ shadow/48752.tmp.10072	2003-09-23 04:22:20.000000000 -0400
@@ -0,0 +1,75 @@
+Bug#: 48752
+Product: Mono/Runtime
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mass@akuma.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: corrupted indexer value causes exception
+
+Description of Problem:
+BenM gave me the following program. It produces an 
+IndexOutOfRangeException, off of the
+            s_CharProperties[i] |= value;
+line. catching the exception, i is set to an incorrect value (~-22000).
+
+class T {
+static void Main () {
+          SetProperties(s_Letter, 2);
+}
+const string s_Letter =
+          "\u0041\u005a\u0061\u007a\u00c0\u00d6\u00d8\u00f6\u30a1
+\u30fa\u3105\u312c\u4e00\u9fa5\uac00\ud7a3";
+static byte [] s_CharProperties = new byte[0xd7a3 + 1];
+
+static void SetProperties (string ranges, byte value) {
+    for (int p = 0; p < ranges.Length; p += 2)
+        for (int i = ranges[p], last = ranges[p + 1]; i <= last; i++)
+            s_CharProperties[i] |= value;
+}
+}
+
+I reduced this recipe to 
+
+using System;
+class T
+{
+    static void Main ()
+    {
+        string letter = "\uac00";
+        int [] charProperties = new int[ 0xac01 ];
+        SetProperties(charProperties, letter, 2);
+    }
+
+    static void SetProperties (int[] cp, string ranges, int val)
+    {
+        cp[ranges[0]] = val;
+    }
+}
+
+Actual Results:
+
+For the second program: 
+
+Unhandled Exception: System.IndexOutOfRangeException: Array index is out 
+of range
+in [0x00003] (at /home/mass/test2.cs:14) .T:SetProperties (int
+[],string,int)
+in [0x00014] (at /home/mass/test2.cs:9) .T:Main ()
+
+Expected Results:
+<no output>
+
+How often does this happen? 
+Always
+
+Additional Information: