bin/ircd: restrict nicknamesn to have a maximum length of nine characters

This commit is contained in:
ghassmo
2022-06-28 01:57:51 +03:00
parent e5bde0c6d1
commit 8e9fcccc7d
2 changed files with 9 additions and 0 deletions

View File

@@ -59,6 +59,10 @@ impl ProtocolPrivmsg {
loop {
let msg = self.msg_sub.receive().await?;
if msg.nickname.len() > 10 {
continue
}
if self.msg_ids.lock().await.contains(&msg.id) {
continue
}

View File

@@ -111,6 +111,11 @@ impl IrcServerConnection {
}
"NICK" => {
let nickname = tokens.next().ok_or(Error::MalformedPacket)?;
if nickname.len() > 10 {
return Ok(())
}
self.is_nick_init = true;
let old_nick = std::mem::replace(&mut self.nickname, nickname.to_string());