dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/String.cs test...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/String.cs test...
Date: Sat, 18 Apr 2009 10:25:05 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnetlib
Changes by:     Klaus Treichel <ktreichel>      09/04/18 10:25:04

Modified files:
        .              : ChangeLog 
        runtime/System : String.cs 
        tests/runtime/System: TestString.cs 

Log message:
        Fix bug #26222 (patch by Thomas Ixiou with some reformatting by me).
        Fix two additional off by one bugs in rangechecking.
        Add testcases for these bugs.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2578&r2=1.2579
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/String.cs?cvsroot=dotgnu-pnet&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/runtime/System/TestString.cs?cvsroot=dotgnu-pnet&r1=1.13&r2=1.14

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2578
retrieving revision 1.2579
diff -u -b -r1.2578 -r1.2579
--- ChangeLog   14 Apr 2009 20:16:45 -0000      1.2578
+++ ChangeLog   18 Apr 2009 10:25:03 -0000      1.2579
@@ -1,3 +1,13 @@
+2009-04-18  Klaus Treichel  <address@hidden>
+
+       * runtime/String.cs: Check for negative count and throw an
+       ArgumentOutOfRangeException in this case.
+       (thanks Thomas Uxiou bug# 26222).
+       Fix off by one bugs in checks of sourceIndex and destinationIndex.
+
+       * tests/runtime/System/TestString.cs: Add additional testcases for
+       the rangechecks in String.CopyTo.
+
 2009-04-14  Thomas Uxiou  <address@hidden>
 
        * System/Net/HttpWebRequest.cs: Fix api compatibility by replacing Close

Index: runtime/System/String.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/String.cs,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- runtime/System/String.cs    22 Feb 2009 16:36:57 -0000      1.45
+++ runtime/System/String.cs    18 Apr 2009 10:25:04 -0000      1.46
@@ -686,18 +686,18 @@
                                {
                                        throw new 
ArgumentNullException("destination");
                                }
-                               if(sourceIndex < 0 || sourceIndex > length)
+                               if(sourceIndex < 0 || sourceIndex >= length)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("sourceIndex", 
_("ArgRange_StringIndex"));
                                }
                                else if(destinationIndex < 0 ||
-                                               destinationIndex > 
destination.Length)
+                                               destinationIndex >= 
destination.Length)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("destinationIndex", 
_("ArgRange_Array"));
                                }
-                               else if((length - sourceIndex) < count ||
+                               else if(count < 0 || (length - sourceIndex) < 
count ||
                                                (destination.Length - 
destinationIndex) < count)
                                {
                                        throw new ArgumentOutOfRangeException

Index: tests/runtime/System/TestString.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/TestString.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- tests/runtime/System/TestString.cs  10 Mar 2005 18:32:25 -0000      1.13
+++ tests/runtime/System/TestString.cs  18 Apr 2009 10:25:04 -0000      1.14
@@ -224,7 +224,7 @@
                try
                {
                        str1.CopyTo(0,(char[])null,0,0);
-                       Fail("str1.CopyTo(0,(char[])null,0,0) should have 
throws a ArgumentNullException");
+                       Fail("str1.CopyTo(0,(char[])null,0,0) should throw an 
ArgumentNullException");
                }
                catch(ArgumentNullException err)
                {
@@ -235,6 +235,33 @@
                        str1.CopyTo(i, c, i, 1); // copy 1 char at a time
                String str2 = new String(c);
                AssertEquals("str1.CopyTo() char by char",str1,str2);
+               try
+               {
+                       str1.CopyTo(0, c, 0, -1);
+                       Fail("str1.CopyTo(0, char[], 0, -1) should throw an 
ArgumentOutOfRangeException");
+               }
+               catch(ArgumentOutOfRangeException e)
+               {
+                       //worked !
+               }
+               try
+               {
+                       str1.CopyTo(0, c, c.Length, 1);
+                       Fail("str1.CopyTo(0, char[], char[].Length, 1) should 
throw an ArgumentOutOfRangeException");
+               }
+               catch(ArgumentOutOfRangeException e)
+               {
+                       //worked !
+               }
+               try
+               {
+                       str1.CopyTo(str1.Length, c, 0, 1);
+                       Fail("str1.CopyTo(str1.Length, char[], 0, 1) should 
throw an ArgumentOutOfRangeException");
+               }
+               catch(ArgumentOutOfRangeException e)
+               {
+                       //worked !
+               }
                // must find a better error message :)
        }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]