From f40fe80a7c69b738bc4021605ac9a2c3bdedc0cb Mon Sep 17 00:00:00 2001 From: Alistair Evans Date: Mon, 7 Nov 2022 13:19:44 +0000 Subject: [PATCH] Improve correctness of ValueIpAddress compares based on family --- src/Enclave.FastPacket/ValueIpAddress.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Enclave.FastPacket/ValueIpAddress.cs b/src/Enclave.FastPacket/ValueIpAddress.cs index 6035340..8a8a261 100644 --- a/src/Enclave.FastPacket/ValueIpAddress.cs +++ b/src/Enclave.FastPacket/ValueIpAddress.cs @@ -141,9 +141,18 @@ public override bool Equals(object? obj) /// 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; } ///