static int clean_nick(const char *, int loc_client);
static int clean_username(const char *);
static int clean_host(const char *);
-static int clean_uid(const char *uid);
+static int clean_uid(const char *uid, const char *sid);
static void set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick);
static void change_local_nick(struct Client *client_p, struct Client *source_p, char *nick, int);
struct Client *, int, const char **, time_t, const char *);
/* mr_nick()
- * parv[0] = sender prefix
* parv[1] = nickname
*/
static int
{
struct Client *target_p;
char nick[NICKLEN];
- char *s;
if (strlen(client_p->id) == 3)
{
return 0;
}
- if(parc < 2 || EmptyString(parv[1]) || (parv[1][0] == '~'))
+ if(parc < 2 || EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
me.name, EmptyString(source_p->name) ? "*" : source_p->name);
return 0;
}
- /* due to the scandinavian origins, (~ being uppercase of ^) and ~
- * being disallowed as a nick char, we need to chop the first ~
- * instead of just erroring.
- */
- if((s = strchr(parv[1], '~')))
- *s = '\0';
-
/* copy the nick and terminate it */
- rb_strlcpy(nick, parv[1], sizeof(nick));
+ rb_strlcpy(nick, parv[1], ConfigFileEntry.nicklen);
/* check the nickname is ok */
if(!clean_nick(nick, 1))
{
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
- me.name, EmptyString(parv[0]) ? "*" : parv[0], parv[1]);
+ me.name, EmptyString(source_p->name) ? "*" : source_p->name, parv[1]);
return 0;
}
}
/* m_nick()
- * parv[0] = sender prefix
* parv[1] = nickname
*/
static int
{
struct Client *target_p;
char nick[NICKLEN];
- char *s;
- if(parc < 2 || EmptyString(parv[1]) || (parv[1][0] == '~'))
+ if(parc < 2 || EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), me.name, source_p->name);
return 0;
}
- /* due to the scandinavian origins, (~ being uppercase of ^) and ~
- * being disallowed as a nick char, we need to chop the first ~
- * instead of just erroring.
- */
- if((s = strchr(parv[1], '~')))
- *s = '\0';
-
/* mark end of grace period, to prevent nickflooding */
if(!IsFloodDone(source_p))
flood_endgrace(source_p);
/* terminate nick to NICKLEN, we dont want clean_nick() to error! */
- rb_strlcpy(nick, parv[1], sizeof(nick));
+ rb_strlcpy(nick, parv[1], ConfigFileEntry.nicklen);
/* check the nickname is ok */
if(!clean_nick(nick, 1))
{
- sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, parv[0], nick);
+ sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME), me.name, source_p->name, nick);
return 0;
}
change_local_nick(client_p, source_p, nick, 1);
}
else
- sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, parv[0], nick);
+ sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, source_p->name, nick);
return 0;
}
/* mc_nick()
*
* server -> server nick change
- * parv[0] = sender prefix
* parv[1] = nickname
* parv[2] = TS when nick change
*/
return 0;
}
- if(!clean_uid(parv[8]))
+ if(!clean_uid(parv[8], source_p->id))
{
rb_snprintf(squitreason, sizeof squitreason,
- "Invalid UID %s for nick %s on %s",
- parv[8], parv[1], source_p->name);
+ "Invalid UID %s for nick %s on %s/%s",
+ parv[8], parv[1], source_p->name, source_p->id);
exit_client(client_p, client_p, client_p, squitreason);
return 0;
}
{
char *s = LOCAL_COPY(parv[9]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Long realname from server %s for %s",
- parv[0], parv[1]);
+ source_p->name, parv[1]);
s[REALLEN] = '\0';
parv[9] = s;
}
return 0;
}
- if(!clean_uid(parv[8]))
+ if(!clean_uid(parv[8], source_p->id))
{
rb_snprintf(squitreason, sizeof squitreason,
- "Invalid UID %s for nick %s on %s",
- parv[8], parv[1], source_p->name);
+ "Invalid UID %s for nick %s on %s/%s",
+ parv[8], parv[1], source_p->name, source_p->id);
exit_client(client_p, client_p, client_p, squitreason);
return 0;
}
{
char *s = LOCAL_COPY(parv[11]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Long realname from server %s for %s",
- parv[0], parv[1]);
+ source_p->name, parv[1]);
s[REALLEN] = '\0';
parv[11] = s;
}
}
/* nicklen is +1 */
- if(len >= NICKLEN)
+ if(len >= NICKLEN && len >= ConfigFileEntry.nicklen)
return 0;
return 1;
}
static int
-clean_uid(const char *uid)
+clean_uid(const char *uid, const char *sid)
{
int len = 1;
+ if(strncmp(uid, sid, strlen(sid)))
+ return 0;
+
if(!IsDigit(*uid++))
return 0;
source_p->name, nick, source_p->username, source_p->host);
/* send the nick change to the users channels */
- sendto_common_channels_local(source_p, ":%s!%s@%s NICK :%s",
+ sendto_common_channels_local(source_p, NOCAPS, ":%s!%s@%s NICK :%s",
source_p->name, source_p->username, source_p->host, nick);
/* send the nick change to servers.. */
monitor_signoff(source_p);
}
- sendto_common_channels_local(source_p, ":%s!%s@%s NICK :%s",
+ sendto_common_channels_local(source_p, NOCAPS, ":%s!%s@%s NICK :%s",
source_p->name, source_p->username, source_p->host, nick);
if(source_p->user)
(void) exit_client(client_p, target_p, &me, "Nick collision");
}
- register_client(client_p, parc >= 10 ? source_p : NULL,
+ register_client(client_p, source_p,
nick, newts, parc, parv);
return 0;
{
ServerStats.is_kill++;
- sendto_one_numeric(target_p, ERR_NICKCOLLISION,
- form_str(ERR_NICKCOLLISION), target_p->name);
+ sendto_one_numeric(source_p, ERR_NICKCOLLISION,
+ form_str(ERR_NICKCOLLISION), source_p->name);
/* kill the client issuing the nickchange */
kill_client_serv_butone(client_p, source_p,
const char *m;
int flag;
- if(server == NULL)
- {
- if((server = find_server(NULL, parv[7])) == NULL)
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "Ghost killed: %s on invalid server %s",
- nick, parv[7]);
- sendto_one(client_p, ":%s KILL %s :%s (Server doesn't exist)",
- get_id(&me, client_p), nick, me.name);
- return 0;
- }
- }
-
source_p = make_client(client_p);
user = make_user(source_p);
rb_dlinkAddTail(source_p, &source_p->node, &global_client_list);
}
else
{
- rb_strlcpy(source_p->info, parv[8], sizeof(source_p->info));
+ s_assert(0);
}
/* remove any nd entries for this nick */
rb_dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
- /* fake direction */
- if(source_p->servptr->from != source_p->from)
- {
- struct Client *target_p = source_p->servptr->from;
-
- sendto_realops_snomask(SNO_DEBUG, L_ALL,
- "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
- client_p->name, source_p->name,
- source_p->username, source_p->host,
- server->name, target_p->name, target_p->from->name);
- kill_client(client_p, source_p,
- "%s (NICK from wrong direction (%s != %s))",
- me.name, server->name, target_p->from->name);
- source_p->flags |= FLAGS_KILLED;
- return exit_client(source_p, source_p, &me, "USER server wrong direction");
- }
-
call_hook(h_new_remote_user, source_p);
return (introduce_client(client_p, source_p, user, nick, parc == 12));