From 6aa9a56242bc16a8b91e798790e96f21528b3fed Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 26 May 2020 10:56:24 -0400 Subject: [PATCH] fix #1057 --- irc/handlers.go | 12 +++++++++--- irc/server.go | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index c789efea..665c3d89 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2503,12 +2503,18 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp return false } - err := client.SetNames(msg.Params[0], msg.Params[3], false) + username, realname := msg.Params[0], msg.Params[3] + if len(realname) == 0 { + rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), client.t("Not enough parameters")) + return false + } + + err := client.SetNames(username, realname, false) if err == errInvalidUsername { // if client's using a unicode nick or something weird, let's just set 'em up with a stock username instead. // fixes clients that just use their nick as a username so they can still use the interesting nick - if client.preregNick == msg.Params[0] { - client.SetNames("user", msg.Params[3], false) + if client.preregNick == username { + client.SetNames("user", realname, false) } else { rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.Nick(), client.t("Malformed username")) } diff --git a/irc/server.go b/irc/server.go index 053d5d3a..bce3a101 100644 --- a/irc/server.go +++ b/irc/server.go @@ -206,7 +206,9 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) { } // try to complete registration normally - if c.preregNick == "" || !c.HasUsername() || session.capState == caps.NegotiatingState { + // XXX(#1057) username can be filled in by an ident query without the client + // having sent USER: check for both username and realname to ensure they did + if c.preregNick == "" || c.username == "" || c.realname == "" || session.capState == caps.NegotiatingState { return }