From 5bb94efaf6b865f5e52404bf9b9dfc3d638369d7 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 10 Apr 2026 10:32:09 -0700 Subject: [PATCH] fix handling of invalid API bearer tokens (#2380) Not doing a pointfix since this only affects obvious misconfigurations of Ergo (our attempt to be defensive against those misconfigurations failed) --- irc/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/irc/config.go b/irc/config.go index d6d64cec..b2d346d7 100644 --- a/irc/config.go +++ b/irc/config.go @@ -1032,12 +1032,12 @@ func (config *Config) processAPI() (err error) { return errors.New("config.api.enabled is true, but listener address is empty") } - config.API.bearerTokenBytes = make([][]byte, len(config.API.BearerTokens)) - for i, tok := range config.API.BearerTokens { + config.API.bearerTokenBytes = make([][]byte, 0, len(config.API.BearerTokens)) + for _, tok := range config.API.BearerTokens { if tok == "" || tok == "example" { continue } - config.API.bearerTokenBytes[i] = []byte(tok) + config.API.bearerTokenBytes = append(config.API.bearerTokenBytes, []byte(tok)) } var tlsConfig *tls.Config