Skip to content

Commit

Permalink
Improve correctness of ValueIpAddress compares based on family
Browse files Browse the repository at this point in the history
  • Loading branch information
enclave-alistair committed Nov 7, 2022
1 parent 5931ec4 commit f40fe80
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Enclave.FastPacket/ValueIpAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ public override bool Equals(object? obj)
/// <inheritdoc />
public bool Equals(ValueIpAddress other)
{
if (_addrFamily != other._addrFamily)
{
return false;
}

if (_addrFamily == AddressFamily.InterNetwork)
{
return _addr1 == other._addr1;
}

return _addr1 == other._addr1 &&
_addr2 == other._addr2 &&
_addrFamily == other._addrFamily;
_addr2 == other._addr2;
}

/// <inheritdoc />
Expand Down

0 comments on commit f40fe80

Please sign in to comment.