Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit fd1bd24

Browse files
author
Ian Hays
committed
Fix UMS 32bit PositionPointer test.
The purpose of the test is to make the PositionPointer setter cast ulong.MaxValue to a long, producing -1 which will always be less than the UMS pointer so the final newPosition will be negative. On a 32 bit system where the pointer length is 4, the max value passable to the PositionPointer setter is uint.MaxValue. So in the test when we cast a value greater than uint.MaxValue to the 4-byte byte* we only get the uint.MaxValue bytes. Since casting a 4-byte pointer to a long will never result in overflow, the AOoRE can never be hit.
1 parent c7f5b4b commit fd1bd24

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/System.IO.UnmanagedMemoryStream/tests/UmsSecurityTest.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public static void ChangePositionViaPointer()
3838
}
3939
}
4040

41-
[ActiveIssue(19444)]
4241
[Fact]
4342
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "NetFX allows a negative Position following some PositionPointer overflowing inputs. See dotnet/coreclr#11376.")]
4443
public static void OverflowPositionPointer()
@@ -50,7 +49,15 @@ public static void OverflowPositionPointer()
5049
ums.PositionPointer = (byte*)0xF0000000;
5150
Assert.Equal(0xB0000000, ums.Position);
5251

53-
Assert.Throws<ArgumentOutOfRangeException>(() => ums.PositionPointer = (byte*)ulong.MaxValue);
52+
if (IntPtr.Size == 4)
53+
{
54+
ums.PositionPointer = (byte*)ulong.MaxValue;
55+
Assert.Equal(uint.MaxValue - 0x40000000, ums.Position);
56+
}
57+
else
58+
{
59+
Assert.Throws<ArgumentOutOfRangeException>(() => ums.PositionPointer = (byte*)ulong.MaxValue);
60+
}
5461
}
5562
}
5663
}

0 commit comments

Comments
 (0)