Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Mayr <mayr_michael@gmx.at>2017-07-03 16:15:06 +0300
committerJan Kotas <jkotas@microsoft.com>2017-07-03 16:15:06 +0300
commit477ca0d52ca39635075b206542b10749d0cac727 (patch)
treee39c52f1b411d6b0dbdf3a3ab22fd2bf0e7e06a8 /src/ILVerify
parent044dbc5b4d69ca1e86957e14d739d42b69bf5b03 (diff)
[ILVerify] Fixed range checks for nested exception regions (#4056)
Diffstat (limited to 'src/ILVerify')
-rw-r--r--src/ILVerify/src/ILImporter.Verify.cs12
-rw-r--r--src/ILVerify/tests/ILTests/ExceptionRegionTests.il42
2 files changed, 50 insertions, 4 deletions
diff --git a/src/ILVerify/src/ILImporter.Verify.cs b/src/ILVerify/src/ILImporter.Verify.cs
index fc732a8a2..30cf77cca 100644
--- a/src/ILVerify/src/ILImporter.Verify.cs
+++ b/src/ILVerify/src/ILImporter.Verify.cs
@@ -170,8 +170,8 @@ namespace Internal.IL
for (int j = 0; j < _exceptionRegions.Length; j++)
{
var r = _exceptionRegions[j].ILRegion;
-
- if (r.TryOffset <= offset && r.TryOffset + r.TryLength >= offset)
+ // Check if offset is within the range [TryOffset, TryOffset + TryLength[
+ if (r.TryOffset <= offset && offset < r.TryOffset + r.TryLength)
{
if (!basicBlock.TryIndex.HasValue)
{
@@ -189,7 +189,8 @@ namespace Internal.IL
}
}
}
- if (r.HandlerOffset <= offset && r.HandlerOffset + r.HandlerLength >= offset)
+ // Check if offset is within the range [HandlerOffset, HandlerOffset + HandlerLength[
+ if (r.HandlerOffset <= offset && offset < r.HandlerOffset + r.HandlerLength)
{
if (!basicBlock.HandlerIndex.HasValue)
{
@@ -207,7 +208,8 @@ namespace Internal.IL
}
}
}
- if(r.FilterOffset != -1 && r.FilterOffset <= offset && r.HandlerOffset - 1 >= offset)
+ // Check if offset is within the range [FilterOffset, HandlerOffset[
+ if (r.FilterOffset != -1 && r.FilterOffset <= offset && offset < r.HandlerOffset )
{
if(!basicBlock.FilterIndex.HasValue)
{
@@ -547,6 +549,8 @@ namespace Internal.IL
if (basicBlock.EntryStack?.Length > 0)
{
+ if (_stack == null || _stack.Length < basicBlock.EntryStack.Length)
+ Array.Resize(ref _stack, basicBlock.EntryStack.Length);
Array.Copy(basicBlock.EntryStack, _stack, basicBlock.EntryStack.Length);
_stackTop = basicBlock.EntryStack.Length;
}
diff --git a/src/ILVerify/tests/ILTests/ExceptionRegionTests.il b/src/ILVerify/tests/ILTests/ExceptionRegionTests.il
new file mode 100644
index 000000000..840643c39
--- /dev/null
+++ b/src/ILVerify/tests/ILTests/ExceptionRegionTests.il
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.assembly extern System.Runtime
+{
+}
+
+.assembly ExceptionRegion
+{
+}
+
+.class public sequential ansi sealed beforefieldinit ExceptionRegionTests
+ extends [System.Runtime]System.Object
+{
+ .method public instance void ExceptionRegion.NestedTryFinally_Valid() cil managed
+ {
+ .try
+ {
+ nop
+ leave EndTryCatch
+ }
+ finally
+ {
+ .try
+ {
+ nop
+ leave EndFinally
+ }
+ catch [System.Runtime]System.Exception
+ {
+ nop
+ leave EndFinally
+ }
+EndFinally:
+ endfinally
+ }
+EndTryCatch:
+ ret
+ }
+}
+