mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 16:42:38 +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"))
|
client.Notice(client.t("*** Looking up your username"))
|
||||||
resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
|
resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
|
||||||
if err == nil {
|
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) {
|
if isIdent(ident) {
|
||||||
identLower := strings.ToLower(ident) // idents can only be ASCII chars only
|
identLower := strings.ToLower(ident) // idents can only be ASCII chars only
|
||||||
client.Notice(client.t("*** Found your username"))
|
client.Notice(client.t("*** Found your username"))
|
||||||
|
@ -2193,7 +2193,11 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||||||
return false
|
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])
|
err := client.SetNames(ident, msg.Params[3])
|
||||||
if err == errInvalidUsername {
|
if err == errInvalidUsername {
|
||||||
|
Loading…
Reference in New Issue
Block a user