From 29e0275ee21a994b6143ff6e78fc5a8867726b06 Mon Sep 17 00:00:00 2001 From: frostycoolslug Date: Thu, 31 Jul 2003 01:00:21 +0000 Subject: [PATCH] Fixed 'Not enough parameters for QUIT Command' bug.. (wtf is that about? :D) Added Ident Verification Possibly fix a minor bug or 2 (Cant remember :)) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@185 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 50 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1f0a84c1c..99cfd5798 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -650,7 +650,36 @@ void strlower(char *n) } } -/* verify that a user's nickname is valid */ +/* verify that a user's ident and nickname is valid */ + +int isident(const char* n) +{ + int i = 0; + char v[MAXBUF]; + if (!n) + + { + return 0; + } + if (!strcmp(n,"")) + { + return 0; + } + for (i = 0; i != strlen(n); i++) + { + if ((n[i] < 33) || (n[i] > 125)) + { + return 0; + } + /* can't occur ANYWHERE in an Ident! */ + if (strchr("<>,./?:;@'~#=+()*&%$£ \"!",n[i])) + { + return 0; + } + } + return 1; +} + int isnick(const char* n) { @@ -3274,11 +3303,18 @@ void handle_user(char **parameters, int pcnt, userrec *user) { if (user->registered < 3) { - WriteServ(user->fd,"NOTICE Auth :No ident response, ident prefixed with ~"); - strcpy(user->ident,"~"); /* we arent checking ident... but these days why bother anyway? */ - strncat(user->ident,parameters[0],IDENTMAX); - strncpy(user->fullname,parameters[3],128); - user->registered = (user->registered | 1); + if (isident(parameters[0]) == 0) { + // This kinda Sucks, According to the RFC thou, its either this, + // or "You have already registered" :p -- Craig + WriteServ(user->fd,"461 %s USER :Not enough parameters",user->nick); + } + else { + WriteServ(user->fd,"NOTICE Auth :No ident response, ident prefixed with ~"); + strcpy(user->ident,"~"); /* we arent checking ident... but these days why bother anyway? */ + strncat(user->ident,parameters[0],IDENTMAX); + strncpy(user->fullname,parameters[3],128); + user->registered = (user->registered | 1); + } } else { @@ -3884,7 +3920,7 @@ void SetupCommandTable(void) { createcommand("USER",handle_user,0,4); createcommand("NICK",handle_nick,0,1); - createcommand("QUIT",handle_quit,0,1); + createcommand("QUIT",handle_quit,0,0); createcommand("VERSION",handle_version,0,0); createcommand("PING",handle_ping,0,1); createcommand("PONG",handle_pong,0,1); -- 2.39.5