Merge pull request #51828 from vvoland/windows-network-none

daemon/libnetwork: Fix panic in findHNSEp when IP networks are nil
This commit is contained in:
Sebastiaan van Stijn
2026-01-08 17:34:36 +01:00
committed by GitHub

View File

@@ -251,9 +251,14 @@ func deleteEpFromResolverImpl(
} }
func findHNSEp(ip4, ip6 *net.IPNet, hnsEndpoints []hcsshim.HNSEndpoint) *hcsshim.HNSEndpoint { func findHNSEp(ip4, ip6 *net.IPNet, hnsEndpoints []hcsshim.HNSEndpoint) *hcsshim.HNSEndpoint {
if ip4 == nil && ip6 == nil {
return nil
}
for _, hnsEp := range hnsEndpoints { for _, hnsEp := range hnsEndpoints {
if (hnsEp.IPAddress != nil && hnsEp.IPAddress.Equal(ip4.IP)) || if ip4 != nil && hnsEp.IPAddress != nil && hnsEp.IPAddress.Equal(ip4.IP) {
(hnsEp.IPv6Address != nil && hnsEp.IPv6Address.Equal(ip6.IP)) { return &hnsEp
}
if ip6 != nil && hnsEp.IPv6Address != nil && hnsEp.IPv6Address.Equal(ip6.IP) {
return &hnsEp return &hnsEp
} }
} }