diff options
| author | Val Lorentz <progval+git@progval.net> | 2024-07-27 16:37:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-27 16:37:16 +0200 |
| commit | acf8409c60ccc96beed0a1f990c4f9374823c0ce (patch) | |
| tree | 09aa97cc7e55b5d58420bc41c5f97494ea604bc5 | |
| parent | 02a572d829e372eb32b3d4187b43e1dc9a553283 (diff) | |
| download | ngircd-acf8409c60ccc96beed0a1f990c4f9374823c0ce.tar.gz ngircd-acf8409c60ccc96beed0a1f990c4f9374823c0ce.zip | |
MODE: Reply with ERR_NOSUCHCHANNEL when the target is a channel (#319)
While it is common for IRC servers to use ERR_NOSUCHNICK instead of ERR_NOSUCHCHANNEL when a target can be either a channel or a nick, it seems every other IRCd but UnrealIRCd uses ERR_NOSUCHCHANNEL in this particular case.
| -rw-r--r-- | src/ngircd/irc-mode.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index 89a07042..adcbbfc5 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -62,6 +62,7 @@ IRC_MODE( CLIENT *Client, REQUEST *Req ) { CLIENT *cl, *origin; CHANNEL *chan; + bool is_valid_nick, is_valid_chan; assert(Client != NULL); assert(Req != NULL); @@ -76,10 +77,12 @@ IRC_MODE( CLIENT *Client, REQUEST *Req ) Client = Client_Search(Req->prefix); /* Channel or user mode? */ + is_valid_nick = Client_IsValidNick(Req->argv[0]); + is_valid_chan = Channel_IsValidName(Req->argv[0]); cl = NULL; chan = NULL; - if (Client_IsValidNick(Req->argv[0])) + if (is_valid_nick) cl = Client_Search(Req->argv[0]); - if (Channel_IsValidName(Req->argv[0])) + if (is_valid_chan) chan = Channel_Search(Req->argv[0]); if (cl) @@ -88,8 +91,12 @@ IRC_MODE( CLIENT *Client, REQUEST *Req ) return Channel_Mode(Client, Req, origin, chan); /* No target found! */ - return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG, - Client_ID(Client), Req->argv[0]); + if (is_valid_nick) + return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG, + Client_ID(Client), Req->argv[0]); + else + return IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG, + Client_ID(Client), Req->argv[0]); } /* IRC_MODE */ /** |