[Mono-bugs] [Bug 70471][Nor] New - Invalid Read with "\u00FF\u00FF" on BinaryReader

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 11 Dec 2004 17:43:27 -0500 (EST)


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 bmaurer@users.sf.net.

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

--- shadow/70471	2004-12-11 17:43:27.000000000 -0500
+++ shadow/70471.tmp.20263	2004-12-11 17:43:27.000000000 -0500
@@ -0,0 +1,69 @@
+Bug#: 70471
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Invalid Read with "\u00FF\u00FF" on BinaryReader
+
+For the following program:
+
+using System;
+using System.IO;
+using System.Text;
+
+class X {
+	static void Main ()
+	{	
+		MemoryStream s = new MemoryStream ();
+		
+		StreamWriter sw = new StreamWriter (s, Encoding.UTF8);
+		sw.Write("\u00FF\u00FF");
+		sw.Flush ();
+		
+		Console.WriteLine (BitConverter.ToString (s.ToArray ()));
+		
+		s.Position = 0;
+		BinaryReader sr = new BinaryReader (s);
+
+		int r = sr.Read ();
+		Console.WriteLine (r);
+		
+		r = sr.Read ();
+		Console.WriteLine (r);
+		if (r != 0xFF)
+			Console.WriteLine ("WRONG!!! 1");
+		
+		r = sr.Read ();
+		Console.WriteLine (r);
+		if (r != 0xFF)
+			Console.WriteLine ("WRONG!!! 2");
+		sr.Close();
+	}
+}
+
+
+Mono gives:
+[benm@omega benm]$ mono t.exe
+EF-BB-BF-C3-BF-C3-BF
+255
+255
+-1
+WRONG!!! 2
+
+While msft gives:
+C:\Inetpub\ftproot>t
+EF-BB-BF-C3-BF-C3-BF
+65279
+255
+255