From: Andrew Hoefling Date: Wed, 6 Mar 2019 01:31:19 +0000 (-0500) Subject: Added new RemoveRange validation check to see if the resulting range (index + count... X-Git-Tag: submit/tizen/20210909.063632~11030^2~2225 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9de202a860a669e31acbc57c9f677216b466d0b;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Added new RemoveRange validation check to see if the resulting range (index + count) > items.Count and if it is true throw ArgumentException Commit migrated from https://github.com/dotnet/coreclr/commit/f48e28bbd7e14fe9b6c708fe57624324a5e604eb --- diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs index 1a83b3f..16939e4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs @@ -209,12 +209,17 @@ namespace System.Collections.ObjectModel if ((uint)index > (uint)items.Count) { - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert); + ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } if (count < 0) { - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_ListInsert); + ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); + } + + if ((Int64)index + (Int64)count > items.Count) + { + ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } int length = items.Count;