mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Avoiding a crash when getting a short ident is a good thing
This commit is contained in:
parent
151002e232
commit
e8309aee79
@ -176,7 +176,10 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) {
|
||||
client.Notice(client.t("*** Looking up your username"))
|
||||
resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
|
||||
if err == nil {
|
||||
ident := resp.Identifier[:config.Limits.IdentLen-1]
|
||||
ident := resp.Identifier
|
||||
if config.Limits.IdentLen < len(ident) {
|
||||
ident = ident[:config.Limits.IdentLen]
|
||||
}
|
||||
if isIdent(ident) {
|
||||
identLower := strings.ToLower(ident) // idents can only be ASCII chars only
|
||||
client.Notice(client.t("*** Found your username"))
|
||||
|
@ -2193,7 +2193,11 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
return false
|
||||
}
|
||||
|
||||
ident := msg.Params[0][:server.Limits().IdentLen-1] // -1 as SetNames adds the ~ at the start for us
|
||||
ident := msg.Params[0]
|
||||
identLen := server.Limits().IdentLen
|
||||
if identLen-1 < len(ident) {
|
||||
ident = ident[:server.Limits().IdentLen-1] // -1 as SetNames adds the ~ at the start for us
|
||||
}
|
||||
|
||||
err := client.SetNames(ident, msg.Params[3])
|
||||
if err == errInvalidUsername {
|
||||
|
Loading…
Reference in New Issue
Block a user