From fe93c5fac6d58b83408e83b81a75d063ef8ca74a Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 22 Nov 2022 11:46:27 -0500 Subject: [PATCH] Fix panic when improperly parsing protocol ports from ER hello. Fixes #1253 --- controller/sync_strats/sync_instant.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/controller/sync_strats/sync_instant.go b/controller/sync_strats/sync_instant.go index fd9dde249..c3050b14e 100644 --- a/controller/sync_strats/sync_instant.go +++ b/controller/sync_strats/sync_instant.go @@ -34,7 +34,6 @@ import ( cmap "github.com/orcaman/concurrent-map/v2" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" - "strings" "sync/atomic" "time" ) @@ -406,10 +405,12 @@ func (strategy *InstantStrategy) ReceiveClientHello(r *network.Router, respHello protocols[listener.Advertise.Protocol] = fmt.Sprintf("%s://%s:%d", listener.Advertise.Protocol, listener.Advertise.Hostname, listener.Advertise.Port) } } else { - for _, p := range respHello.ProtocolPorts { - parts := strings.Split(p, ":") - ingressUrl := fmt.Sprintf("%s://%s:%s", parts[0], respHello.Hostname, parts[1]) - protocols[parts[0]] = ingressUrl + for idx, protocol := range respHello.Protocols { + if len(respHello.ProtocolPorts) > idx { + port := respHello.ProtocolPorts[idx] + ingressUrl := fmt.Sprintf("%s://%s:%s", protocol, respHello.Hostname, port) + protocols[protocol] = ingressUrl + } } }