Inconsistent IPNetwork.Contains behavior for prefixes which are not at start of subnet range. #6674
Labels
area-middleware
Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
bug
This issue describes a behavior which is not expected - a bug.
good first issue
Good for newcomers.
help wanted
Up for grabs. We would accept a PR to help resolve this issue
Milestone
Describe the bug
In AspNetCore/src/Middleware/HttpOverrides/src/IPNetwork.cs
The code below assumes that the prefix will have all bits in position > mask length set to 0. I do not believe that this a requirement for CIDR notation. If it is, it is not applied consistently since the routine will break if the mask is == 0 at a given byte.
To Reproduce
Create instance with Prefix/Prefix Length 192.168.0.1/31.
Contains returns false for 192.168.0.0.
Expected behavior
Expectation is that 192.168.0.1/31 would match 192.168.0.0
The text was updated successfully, but these errors were encountered: