From 222314268598cc1fb784681a5ab0d41c3a2cc712 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Jul 2019 09:42:42 -0400 Subject: [PATCH] embed: fix oob panic in zap logger This fixes an index out-of-bounds panic caused when using the embed package and the zap logger. When a TLS handshake error is logged, the slice for cert ip addresses is allocated with capacity but no length, so subsequent index access causes the panic, and doesn't surface the TLS handshake error to the user. Fixes #10932 --- embed/config_logging.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embed/config_logging.go b/embed/config_logging.go index bddaacabe..0478fb444 100644 --- a/embed/config_logging.go +++ b/embed/config_logging.go @@ -242,7 +242,7 @@ func (cfg *Config) setupLogging() error { serverName := state.ServerName if len(state.PeerCertificates) > 0 { cert := state.PeerCertificates[0] - ips := make([]string, 0, len(cert.IPAddresses)) + ips := make([]string, len(cert.IPAddresses)) for i := range cert.IPAddresses { ips[i] = cert.IPAddresses[i].String() }