Procházet zdrojové kódy

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
chris před 7 roky
rodič
revize
2223142685
1 změnil soubory, kde provedl 1 přidání a 1 odebrání
  1. 1 1
      embed/config_logging.go

+ 1 - 1
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()
 				}