Browse Source

USER: disallow usernames that break the protocol

tags/v0.1.0
Daniel Oaks 8 years ago
parent
commit
199f8bd8ae
2 changed files with 7 additions and 1 deletions
  1. 0
    1
      irc/client.go
  2. 7
    0
      irc/server.go

+ 0
- 1
irc/client.go View File

@@ -88,7 +88,6 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
88 88
 			//TODO(dan): replace this with IsUsername/IsIRCName?
89 89
 			if Name(username).IsNickname() {
90 90
 				client.Notice("*** Found your username")
91
-				//TODO(dan): we do a bunch of user replacing in server.go userHandler, do we need that here?
92 91
 				client.username = Name(username)
93 92
 				// we don't need to updateNickMask here since nickMask is not used for anything yet
94 93
 			} else {

+ 7
- 0
irc/server.go View File

@@ -400,6 +400,13 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
400 400
 		return false
401 401
 	}
402 402
 
403
+	// confirm that username is valid
404
+	//
405
+	if !Name(msg.Params[0]).IsNickname() {
406
+		client.Send(nil, "", "ERROR", "Malformed username")
407
+		return true
408
+	}
409
+
403 410
 	// set user info and log client in
404 411
 	//TODO(dan): Could there be a race condition here with adding/removing the client?
405 412
 	//TODO(dan): we should do something like server.clients.Replace(client) instead

Loading…
Cancel
Save