channel: cap the per-channel invite set (maxinvites, default 100) — it only shrank when the invitee joined, so an op could grow it unboundedly; re-inviting an already-listed nick still works

This commit is contained in:
Jean Chevronnet 2026-08-19 01:22:32 +00:00
parent 8f5b37bf8d
commit d495fd0f30

View file

@ -309,6 +309,17 @@ impl Command for Invite {
); );
return CmdResult::Fail; return CmdResult::Fail;
} }
// cap the per-channel invite set — it only grows until the invitee joins, so
// without a bound an op could grow it indefinitely (like maxbans caps +b).
let maxinv = s.conf_num("maxinvites", 100usize);
if s.channels[&key].invites.len() >= maxinv && !s.channels[&key].invites.contains(&tuid) {
let nick = s.users.get(&uid).map(|u| u.nick.clone()).unwrap_or_default();
s.send(
uid,
format!(":{} NOTICE {nick} :{chan} :Channel invite list is full", s.name),
);
return CmdResult::Fail;
}
if let Some(ch) = s.channels.get_mut(&key) { if let Some(ch) = s.channels.get_mut(&key) {
ch.invites.insert(tuid); ch.invites.insert(tuid);
} }