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
 			//TODO(dan): replace this with IsUsername/IsIRCName?
88
 			//TODO(dan): replace this with IsUsername/IsIRCName?
89
 			if Name(username).IsNickname() {
89
 			if Name(username).IsNickname() {
90
 				client.Notice("*** Found your username")
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
 				client.username = Name(username)
91
 				client.username = Name(username)
93
 				// we don't need to updateNickMask here since nickMask is not used for anything yet
92
 				// we don't need to updateNickMask here since nickMask is not used for anything yet
94
 			} else {
93
 			} else {

+ 7
- 0
irc/server.go View File

400
 		return false
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
 	// set user info and log client in
410
 	// set user info and log client in
404
 	//TODO(dan): Could there be a race condition here with adding/removing the client?
411
 	//TODO(dan): Could there be a race condition here with adding/removing the client?
405
 	//TODO(dan): we should do something like server.clients.Replace(client) instead
412
 	//TODO(dan): we should do something like server.clients.Replace(client) instead

Loading…
Cancel
Save