[mono/xsp] [2 commits] b42080a0: [FastCgi] Fix off-by-one error in CompatArraySegment

"Marek Habersack ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141bbadfea9-e8fbdb37-bca4-4d73-bd21-ee6bfa113bd5-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/xsp
  Compare: https://github.com/mono/xsp/compare/dfe52823c6cd...d3a882a489d0

   Commit: b42080a0281f81ff92edd49fba8549c7aee618fe
   Author: Leonardo Taglialegne <[email protected]> (miniBill)
     Date: 2013-10-14 22:06:20 GMT
      URL: https://github.com/mono/xsp/commit/b42080a0281f81ff92edd49fba8549c7aee618fe

[FastCgi] Fix off-by-one error in CompatArraySegment

Changed paths:
  M src/Mono.WebServer.FastCgi/Compatibility/CompatArraySegment.cs
  M src/Mono.WebServer.Test/CompatArraySegmentTest.cs

Modified: src/Mono.WebServer.FastCgi/Compatibility/CompatArraySegment.cs
===================================================================
@@ -62,13 +62,13 @@ public struct CompatArraySegment<T>
 
 		public T this[int index] {
 			get {
-				if (index < 0 || count < index)
+				if (index < 0 || count <= index)
 					throw new ArgumentOutOfRangeException ("index");
 
 				return array[offset + index];
 			}
 			set {
-				if (index < 0 || count < index)
+				if (index < 0 || count <= index)
 					throw new ArgumentOutOfRangeException ("index");
 
 				array[offset + index] = value;

Modified: src/Mono.WebServer.Test/CompatArraySegmentTest.cs
===================================================================
@@ -28,6 +28,7 @@
 
 using Mono.WebServer.FastCgi.Compatibility;
 using NUnit.Framework;
+using System;
 
 namespace Mono.WebServer.Test {
 	[TestFixture]
@@ -40,6 +41,13 @@ public void TestCase ()
 
 			test [0] = -3;
 			Assert.AreEqual (-3, test [0]);
+
+			try {
+				var test2 = new CompatArraySegment<int> (new int[1]);
+				test2 [1] = 0;
+				Assert.Fail ("Out of range access");
+			} catch (ArgumentOutOfRangeException) {
+			}
 		}
 	}
 }

   Commit: d3a882a489d069adf93f50bec46216b65c72c5c6
   Author: Marek Habersack <[email protected]> (grendello)
     Date: 2013-10-15 10:31:19 GMT
      URL: https://github.com/mono/xsp/commit/d3a882a489d069adf93f50bec46216b65c72c5c6

Merge pull request #64 from miniBill/master

[FastCgi] Fix off-by-one error in CompatArraySegment

Changed paths:
  M src/Mono.WebServer.FastCgi/Compatibility/CompatArraySegment.cs
  M src/Mono.WebServer.Test/CompatArraySegmentTest.cs

Modified: src/Mono.WebServer.FastCgi/Compatibility/CompatArraySegment.cs
===================================================================
@@ -62,13 +62,13 @@ public struct CompatArraySegment<T>
 
 		public T this[int index] {
 			get {
-				if (index < 0 || count < index)
+				if (index < 0 || count <= index)
 					throw new ArgumentOutOfRangeException ("index");
 
 				return array[offset + index];
 			}
 			set {
-				if (index < 0 || count < index)
+				if (index < 0 || count <= index)
 					throw new ArgumentOutOfRangeException ("index");
 
 				array[offset + index] = value;

Modified: src/Mono.WebServer.Test/CompatArraySegmentTest.cs
===================================================================
@@ -28,6 +28,7 @@
 
 using Mono.WebServer.FastCgi.Compatibility;
 using NUnit.Framework;
+using System;
 
 namespace Mono.WebServer.Test {
 	[TestFixture]
@@ -40,6 +41,13 @@ public void TestCase ()
 
 			test [0] = -3;
 			Assert.AreEqual (-3, test [0]);
+
+			try {
+				var test2 = new CompatArraySegment<int> (new int[1]);
+				test2 [1] = 0;
+				Assert.Fail ("Out of range access");
+			} catch (ArgumentOutOfRangeException) {
+			}
 		}
 	}
 }


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.