Explorar el Código

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 hace 6 años
padre
commit
2223142685
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  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()
 				}