diff options
| author | Alexander Barton <alex@barton.de> | 2012-09-26 23:28:13 +0200 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2012-09-26 23:28:13 +0200 |
| commit | 005340c83f3f481bdcdc6a03ae9b9b2973248ceb (patch) | |
| tree | cc3ce376c7fe4e7f424e06fe40bb185f9555799b | |
| parent | d21afce2b6fdc919a80c4eb1d6ba781c1cf63f3c (diff) | |
| download | ngircd-005340c83f3f481bdcdc6a03ae9b9b2973248ceb.tar.gz ngircd-005340c83f3f481bdcdc6a03ae9b9b2973248ceb.zip | |
Simplify check for valid user names in IRC_USER().
Patches from Federico G. Schwindt, thanks! (cherry picked from commit a44b7126227ba1118ec02b399e31b08102af5e8c and 6fbe9583753b2620da275676cde46a89cb4d06c2)
| -rw-r--r-- | src/ngircd/irc-login.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index 74d8b9d1..99cd26f4 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -18,6 +18,7 @@ #include "imp.h" #include <assert.h> +#include <ctype.h> #include <stdlib.h> #include <string.h> #include <strings.h> @@ -422,11 +423,9 @@ IRC_USER(CLIENT * Client, REQUEST * Req) punctuation is allowed.*/ ptr = Req->argv[0]; while (*ptr) { - if ((*ptr < '0' || *ptr > '9') && - (*ptr < 'A' || *ptr > 'Z') && - (*ptr < 'a' || *ptr > 'z') && - (*ptr != '+') && (*ptr != '-') && - (*ptr != '.') && (*ptr != '_')) { + if (!isalnum(*ptr) && + *ptr != '+' && *ptr != '-' && + *ptr != '.' && *ptr != '_') { Conn_Close(Client_Conn(Client), NULL, "Invalid user name", true); return DISCONNECTED; |