u_short check_um(user_t *cptr, char *um) { if (strlen(um) > USERLEN) return (cptr ? reply(OS, cptr->nick, "The usermask is too long.") : 1); for (; *um; um++) if (!IsUserChar(*um) && *um != '*' && *um != '?') return (cptr ? reply(OS, cptr->nick, "The character '%c' is not allowed in your usermask.", *um) : 1); return 0; }
int ValidateUserWild( const char *username ) { if( username == NULL ) return NS_FAILURE; while( *username != '\0' ) { if( !IsUserChar( *username ) && !IsWildChar( *username ) ) return NS_FAILURE; username++; } return NS_SUCCESS; }
/* 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; }
/* * valid_username - check username for validity * * Inputs - pointer to user * Output - YES if valid, NO if not * Side effects - NONE * * Absolutely always reject any '*' '!' '?' '@' in an user name * reject any odd control characters names. * Allow '.' in username to allow for "first.last" * style of username */ bool valid_username(const char *username) { int dots = 0; const char *p = username; s_assert(NULL != p); if(username == NULL) return false; if('~' == *p) ++p; /* 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 false; while(*++p) { if((*p == '.') && ConfigFileEntry.dots_in_ident) { dots++; if(dots > ConfigFileEntry.dots_in_ident) return false; if(!IsUserChar(p[1])) return false; } else if(!IsUserChar(*p)) return false; } return true; }
/* clean_user_name() * * input - username * output - none * side effects - walks through the username, returning 0 if erroneous */ static int clean_user_name(char *user) { s_assert(user); if(user == NULL) return 0; for (; *user; user++) { if(!IsUserChar(*user)) return 0; } return 1; }
static int clean_username(const char *username) { int len = 0; for (; *username; username++) { len++; if(!IsUserChar(*username)) return 0; } if(len > USERLEN) return 0; return 1; }
/* * ms_svsident - server message handler * * parv[0] = sender prefix * parv[1] = Target numeric * parv[2] = New ident */ int ms_svsident(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Client *acptr; char *s; char *newident = NULL; int legalident=1; if (parc < 3) return need_more_params(sptr, "SVSIDENT"); /* Ignore SVSIDENT for a user that has quit */ if (!(acptr = findNUser(parv[1]))) return 0; if (IsChannelService(acptr)) return 0; newident = strdup(parv[2]); if (strlen(newident) > USERLEN) return protocol_violation(sptr, "Ident too long in SVSIDENT command"); for (s = newident; *s; s++) { if (!IsUserChar(*s)) { legalident = 0; break; } } if (legalident == 0) return protocol_violation(sptr, "Illegal characters in SVSIDENT ident"); ircd_strncpy(cli_user(acptr)->username, newident, USERLEN); ircd_strncpy(cli_username(acptr), newident, USERLEN); sendcmdto_serv_butone(sptr, CMD_SVSIDENT, cptr, "%s%s %s", acptr->cli_user->server->cli_yxx, acptr->cli_yxx, newident); return 0; }
/* * valid_username - check username for validity * * Inputs - username * Output - 1 for valid, 0 for invalid * * Absolutely always reject any '*' '!' '?' '@' '.' in an user name * reject any odd control characters names. */ int irc_IsValidUsername(const char* username) { const char *p = username; assert(0 != p); if (*p=='\0') return 0; if ('~' == *p) ++p; while (*p) { if (!IsUserChar(*p)) return 0; ++p; } return 1; }
int eval_user_char(char c) { return (0 != IsUserChar(c)); }