[Mono-bugs] [Bug 80459][Maj] Changed - String.Compare for data received over sockets doesn't behave correctly.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jan 5 17:01:13 EST 2007

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 robertj at gmx.net.


--- shadow/80459	2007-01-05 13:44:11.000000000 -0500
+++ shadow/80459.tmp.27555	2007-01-05 17:01:13.000000000 -0500
@@ -1,13 +1,13 @@
 Bug#: 80459
 Product: Mono: Runtime
 Version: 1.2
 OS: GNU/Linux [Other]
 OS Details: 
-Status: REOPENED   
+Status: RESOLVED   
+Resolution: NOTABUG
 Severity: Unknown
 Priority: Major
 Component: misc
 AssignedTo: mono-bugs at ximian.com                            
 ReportedBy: amd at store20.com               
 QAContact: mono-bugs at ximian.com
@@ -79,6 +79,21 @@
 ------- Additional Comments From amd at store20.com  2007-01-05 13:44 -------
 I attached smaller testclient and it isn't a newline issue, because it
 also happens with strings without newlines.
 I also tried changing the encodings to UTF8 and it also resulted same
 problems (on Linux).
+------- Additional Comments From robertj at gmx.net  2007-01-05 17:01 -------
+In testserver.cs rxbuf has the length 1024. After receiving
+from the socket its length it's still 1024 because arrays
+don't shrink in .NET.
+If you call Encoding.GetString on this byte array, it
+will return garbage, because only the fist few bytes contain
+the string.
+You have to use another GetString overload that considers
+the length of the buffer:
+string test1 = Encoding.ASCII.GetString(rxbuf, 0, rxbuflen);

More information about the mono-bugs mailing list