Add sanity checking for modified svcMap while iterating through it.

Suggestion from @DerZade
Fixes https://github.com/moby/moby/pull/43444#discussion_r1033364679
Fixes #43442

Signed-off-by: Martin Ashby <martin@ashbysoft.com>
This commit is contained in:
Martin Ashby 2022-11-30 07:28:45 +00:00
parent 465ec963c8
commit 349c515ef8
No known key found for this signature in database
GPG key ID: 7C2A95403085B982

View file

@ -2001,7 +2001,13 @@ func (n *network) ResolveName(req string, ipType int) ([]net.IP, bool) {
strings.HasSuffix(req, strings.TrimPrefix(key, "*"))) {
selectedKey = key
ok = true
ipSet, _ = sr.svcMap.Get(selectedKey)
var found bool
ipSet, found = sr.svcMap.Get(selectedKey)
if !found {
logrus.Errorf("svcMap changed unexpectedly looking for key %s", key)
continue
}
break
}
}