[Mono-dev] [Mono-patches] r108492 - in branches/mono-2-0/mcs/class/System.Web: System.Web.UI Test/System.Web.UI
Gert Driesen
gert.driesen at telenet.be
Tue Jul 22 15:12:03 EDT 2008
Hi Dean,
Was this change approved for the 2.0 branch, or did you commit it to the
branch by accident?
Also, your patch was not complete; Stream.Length can/will also throw a
NotSupportedException when the stream is unseekable. I'll commit a slighty
modified version to SVN HEAD in a few minutes.
Gert
-----Original Message-----
From: mono-patches-bounces at lists.ximian.com
[mailto:mono-patches-bounces at lists.ximian.com] On Behalf Of Dean Brettle
(dean at brettle.com)
Sent: dinsdag 22 juli 2008 20:21
To: mono-patches at lists.ximian.com; ximian.monolist at gmail.com;
mono-svn-patches-garchive-20758 at googlegroups.com
Subject: [Mono-patches] r108492 - in branches/mono-2-0/mcs/class/System.Web:
System.Web.UI Test/System.Web.UI
Author: deanb
Date: 2008-07-22 14:20:47 -0400 (Tue, 22 Jul 2008)
New Revision: 108492
Modified:
branches/mono-2-0/mcs/class/System.Web/System.Web.UI/ChangeLog
branches/mono-2-0/mcs/class/System.Web/System.Web.UI/LosFormatter.cs
branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/LosFormatterTest.c
s
Log:
++ Test/System.Web.UI/ChangeLog (working copy)
* LosFormatterTest.cs: added test for bug 411115 where passing an
unseekable stream to LosFormatter.Deserialize() causes an exception.
++ System.Web.UI/ChangeLog (working copy)
* LosFormatter.cs: fixed bug 411115 where passing an unseekable
stream to LosFormatter.Deserialize() causes an exception.
Modified: branches/mono-2-0/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- branches/mono-2-0/mcs/class/System.Web/System.Web.UI/ChangeLog
2008-07-22 17:35:55 UTC (rev 108491)
+++ branches/mono-2-0/mcs/class/System.Web/System.Web.UI/ChangeLog
2008-07-22 18:20:47 UTC (rev 108492)
@@ -1,3 +1,8 @@
+2008-07-22 Dean Brettle <dean at brettle.com>
+
+ * LosFormatter.cs: fixed bug 411115 where passing an unseekable
+ stream to LosFormatter.Deserialize() causes an exception.
+
2008-07-14 Marek Habersack <mhabersack at novell.com>
* Page.cs: fix the failing tests by moving the form
Modified:
branches/mono-2-0/mcs/class/System.Web/System.Web.UI/LosFormatter.cs
===================================================================
--- branches/mono-2-0/mcs/class/System.Web/System.Web.UI/LosFormatter.cs
2008-07-22 17:35:55 UTC (rev 108491)
+++ branches/mono-2-0/mcs/class/System.Web/System.Web.UI/LosFormatter.cs
2008-07-22 18:20:47 UTC (rev 108492)
@@ -70,8 +70,10 @@
{
if (stream == null)
throw new ArgumentNullException ("stream");
-
- byte [] bytes = new byte [stream.Length >= 0 ?
stream.Length : 2048];
+ long streamLength = -1;
+ if (stream.CanSeek)
+ streamLength = stream.Length;
+ byte [] bytes = new byte [streamLength >= 0 ?
streamLength : 2048];
MemoryStream ms = null;
if ((stream is MemoryStream) && stream.Position ==
0) {
// We save allocating a new stream and
reading in this case.
Modified:
branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
===================================================================
--- branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
2008-07-22 17:35:55 UTC (rev 108491)
+++ branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
2008-07-22 18:20:47 UTC (rev 108492)
@@ -1,3 +1,8 @@
+2008-07-22 Dean Brettle <dean at brettle.com>
+
+ * LosFormatterTest.cs: added test for bug 411115 where passing an
+ unseekable stream to LosFormatter.Deserialize() causes an exception.
+
2008-06-14 Gert Driesen <drieseng at users.sourceforge.net>
* PageTest.cs: Fixed compile error on MS (as it does not list the
Modified:
branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/LosFormatterTest.c
s
===================================================================
---
branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/LosFormatterTest.c
s 2008-07-22 17:35:55 UTC (rev 108491)
+++
branches/mono-2-0/mcs/class/System.Web/Test/System.Web.UI/LosFormatterTest.c
s 2008-07-22 18:20:47 UTC (rev 108492)
@@ -146,5 +146,34 @@
Assert.AreEqual (string.Empty, s1, "#2");
#endif
}
+
+ [Test] // bug #4111115
+ public void Deserialize_Unseekable ()
+ {
+ string s = "Hello world";
+ LosFormatter lf = new LosFormatter ();
+ MemoryStream ms = new MemoryStream ();
+ lf.Serialize (ms, s);
+ byte[] serializedBytes = ms.ToArray();
+ UnseekableMemoryStream ums
+ = new
UnseekableMemoryStream(serializedBytes, 0, serializedBytes.Length, false,
true);
+ string s2 = lf.Deserialize (ums) as string;
+ Assert.IsNotNull (s2, "#1");
+ Assert.AreEqual (s, s2, "#2");
+ }
+
+ class UnseekableMemoryStream : MemoryStream
+ {
+ public UnseekableMemoryStream(byte[] byteArray, int
index, int count,
+ bool writable, bool
publiclyVisible)
+ : base(byteArray, index, count, writable,
publiclyVisible)
+ {
+ }
+
+ public override bool CanSeek {
+ get { return false; }
+ }
+ }
+
}
}
_______________________________________________
Mono-patches maillist - Mono-patches at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches
More information about the Mono-devel-list
mailing list