summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-05-16 14:47:31 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-05-16 14:47:31 +0000
commita8e48a71c51e8be73d121ed5a9e98ed92caab41f (patch)
tree33a2a46c7fd23782f158cce54e54a95ae2c159e7
parent2a464d5b0612c7789cd56bddf97ac0ee23b7d039 (diff)
- Merged valid_username() and clean_user_name()
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2068 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r--include/s_user.h2
-rw-r--r--modules/core/m_nick.c22
-rw-r--r--src/s_user.c32
3 files changed, 23 insertions, 33 deletions
diff --git a/include/s_user.h b/include/s_user.h
index af05c67..b6f7a2f 100644
--- a/include/s_user.h
+++ b/include/s_user.h
@@ -49,7 +49,7 @@ extern void register_remote_user(struct Client *,
extern void init_uid(void);
extern int valid_sid(const char *);
extern int valid_hostname(const char *);
-extern int valid_username(const char *);
+extern int valid_username(const char *, const int);
extern int valid_nickname(const char *, const int);
extern void add_isupport(const char *, const char *, int);
extern void delete_isupport(const char *);
diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c
index d74d81c..2ac8fe7 100644
--- a/modules/core/m_nick.c
+++ b/modules/core/m_nick.c
@@ -46,26 +46,6 @@
#include "s_misc.h"
-/* clean_user_name()
- *
- * input - username
- * output - none
- * side effects - walks through the username, returning 0 if erroneous
- */
-static int
-clean_user_name(const char *user)
-{
- const char *p = user;
-
- assert(user && *user);
-
- for (; *p; ++p)
- if (!IsUserChar(*p))
- return 0;
-
- return p - user <= USERLEN;
-}
-
/* check_clean_nick()
*
* input - pointer to source
@@ -124,7 +104,7 @@ static int
check_clean_user(struct Client *client_p, char *nick,
char *user, struct Client *server_p)
{
- if (!clean_user_name(user))
+ if (!valid_user_name(user, 0))
{
++ServerStats.is_kill;
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
diff --git a/src/s_user.c b/src/s_user.c
index 5e22121..a6f82d5 100644
--- a/src/s_user.c
+++ b/src/s_user.c
@@ -390,7 +390,7 @@ register_local_user(struct Client *source_p)
}
/* valid user name check */
- if (valid_username(source_p->username) == 0)
+ if (valid_username(source_p->username, 1) == 0)
{
char tmpstr2[IRCD_BUFSIZE];
@@ -674,7 +674,7 @@ valid_hostname(const char *hostname)
* style of username
*/
int
-valid_username(const char *username)
+valid_username(const char *username, const int local)
{
int dots = 0;
const char *p = username;
@@ -684,27 +684,37 @@ valid_username(const char *username)
if (*p == '~')
++p;
- /* reject usernames that don't start with an alphanum
+ /*
+ * Reject usernames that don't start with an alphanum
* i.e. reject jokers who have '-@somehost' or '.@somehost'
* or "-hi-@somehost", "h-----@somehost" would still be accepted.
*/
if (!IsAlNum(*p))
return 0;
- while (*++p)
+ if (local)
{
- if ((*p == '.') && ConfigFileEntry.dots_in_ident)
+ while (*++p)
{
- if (++dots > ConfigFileEntry.dots_in_ident)
- return 0;
- if (!IsUserChar(*(p + 1)))
+ if ((*p == '.') && ConfigFileEntry.dots_in_ident)
+ {
+ if (++dots > ConfigFileEntry.dots_in_ident)
+ return 0;
+ if (!IsUserChar(*(p + 1)))
+ return 0;
+ }
+ else if (!IsUserChar(*p))
return 0;
}
- else if (!IsUserChar(*p))
- return 0;
+ }
+ else
+ {
+ while (*++p)
+ if (!IsUserChar(*p))
+ return 0;
}
- return 1;
+ return p - username <= USERLEN;;
}
/* clean_nick_name()