safer 005 length limits (#2241)

* Limit the payload to 380 bytes instead of 400
* Don't translate the final parameter

This leaves about 60 bytes for the server name.
This commit is contained in:
Shivaram Lingamneni 2025-04-06 02:59:03 -04:00 committed by GitHub
parent 98e04c10a8
commit 9c3173f573
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View file

@ -520,14 +520,14 @@ func (server *Server) sendRplISupportLines(client *Client, rb *ResponseBuffer, l
batchID := rb.StartNestedBatch(caps.ExtendedISupportBatchType)
defer rb.EndNestedBatch(batchID)
}
translatedISupport := client.t("are supported by this server")
finalText := "are supported by this server"
nick := client.Nick()
for _, cachedTokenLine := range lines {
length := len(cachedTokenLine) + 2
tokenline := make([]string, length)
tokenline[0] = nick
copy(tokenline[1:], cachedTokenLine)
tokenline[length-1] = translatedISupport
tokenline[length-1] = finalText
rb.Add(nil, server.name, RPL_ISUPPORT, tokenline...)
}
}