ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svsnick.c
Revision: 9274
Committed: Wed Feb 12 18:46:30 2020 UTC (6 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5001 byte(s)
Log Message:
- Reduce size of some user mode relevant buffers from IRCD_BUFSIZE (512) to UMODE_MAX_STR (56)

File Contents

# User Rev Content
1 michael 1165 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 michael 1165 *
4 michael 2820 * Copyright (c) 1999 Bahamut development team.
5 michael 9101 * Copyright (c) 2011-2020 ircd-hybrid development team
6 michael 1165 *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 michael 1165 * USA
21     */
22    
23     /*! \file m_svsnick.c
24 michael 1221 * \brief Includes required functions for processing the SVSNICK command.
25 michael 1165 * \version $Id$
26     */
27    
28 michael 2820
29 michael 1165 #include "stdinc.h"
30     #include "client.h"
31     #include "ircd.h"
32 michael 9234 #include "channel.h"
33 michael 1165 #include "channel_mode.h"
34     #include "send.h"
35     #include "parse.h"
36     #include "modules.h"
37     #include "irc_string.h"
38 michael 3347 #include "user.h"
39 michael 1165 #include "hash.h"
40     #include "watch.h"
41     #include "whowas.h"
42    
43    
44 michael 3300 /*! \brief SVSNICK command handler
45 michael 1165 *
46     * \param source_p Pointer to allocated Client struct from which the message
47     * originally comes from. This can be a local or remote client.
48     * \param parc Integer holding the number of supplied arguments.
49     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
50     * pointers.
51     * \note Valid arguments for this command are:
52 michael 3096 * - parv[0] = command
53 michael 1165 * - parv[1] = old nickname
54 michael 7856 * - parv[2] = old timestamp
55 michael 7855 * - parv[3] = new nickname
56     * - parv[4] = new timestamp
57 michael 1165 */
58 michael 9077 static void
59 michael 3156 ms_svsnick(struct Client *source_p, int parc, char *parv[])
60 michael 1165 {
61 michael 7855 const char *new_nick = parc == 5 ? parv[3] : parv[2]; /* TBR: compatibility mode */
62     uintmax_t ts = 0, new_ts = 0;
63 michael 1165
64 michael 7469 if (!HasFlag(source_p, FLAGS_SERVICE))
65 michael 9077 return;
66 michael 1165
67 michael 8660 if (valid_nickname(new_nick, true) == false)
68 michael 9077 return;
69 michael 7469
70 michael 9272 struct Client *target_p = find_person(source_p, parv[1]);
71     if (target_p == NULL)
72 michael 9077 return;
73 michael 1165
74 michael 7855 if (parc == 5) /* TBR: compatibility mode */
75     {
76     ts = strtoumax(parv[2], NULL, 10);
77     if (ts && (ts != target_p->tsinfo))
78 michael 9077 return;
79 michael 7855 }
80     else /* parc == 4 */
81     ts = strtoumax(parv[3], NULL, 10);
82    
83     if (parc == 4) /* TBR: compatibility mode */
84     new_ts = ts;
85     else
86     new_ts = strtoumax(parv[4], NULL, 10);
87    
88 michael 3967 if (!MyConnect(target_p))
89     {
90     if (target_p->from == source_p->from)
91     {
92     sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
93     "Received wrong-direction SVSNICK "
94     "for %s (behind %s) from %s",
95     target_p->name, source_p->from->name,
96 michael 7997 client_get_name(source_p, HIDE_IP));
97 michael 9077 return;
98 michael 3967 }
99    
100     sendto_one(target_p, ":%s SVSNICK %s %s %s", source_p->id,
101 michael 7855 target_p->id, new_nick, parv[3]);
102 michael 9077 return;
103 michael 3967 }
104 michael 1165
105 michael 9272 struct Client *exists_p = hash_find_client(new_nick);
106     if (exists_p)
107 michael 1165 {
108 michael 3138 if (target_p == exists_p)
109     {
110 michael 8603 if (strcmp(target_p->name, new_nick) == 0)
111 michael 9077 return;
112 michael 3138 }
113     else if (IsUnknown(exists_p))
114 michael 3171 exit_client(exists_p, "SVSNICK Override");
115 michael 1165 else
116     {
117 michael 3171 exit_client(target_p, "SVSNICK Collide");
118 michael 9077 return;
119 michael 1165 }
120     }
121    
122 michael 7855 target_p->tsinfo = new_ts;
123 michael 7764 clear_ban_cache_list(&target_p->channel);
124 michael 1165 watch_check_hash(target_p, RPL_LOGOFF);
125    
126     if (HasUMode(target_p, UMODE_REGISTERED))
127     {
128 michael 5548 const unsigned int oldmodes = target_p->umodes;
129 michael 9274 char buf[UMODE_MAX_STR] = "";
130 michael 1165
131     DelUMode(target_p, UMODE_REGISTERED);
132 michael 9272 send_umode(target_p, true, oldmodes, buf);
133 michael 1165 }
134    
135 michael 8688 sendto_common_channels_local(target_p, true, 0, 0, ":%s!%s@%s NICK :%s",
136 michael 1165 target_p->name, target_p->username,
137 michael 7855 target_p->host, new_nick);
138 michael 1165
139 michael 8664 whowas_add_history(target_p, true);
140 michael 1165
141 michael 6782 sendto_server(NULL, 0, 0, ":%s NICK %s :%ju",
142 michael 7855 target_p->id, new_nick, target_p->tsinfo);
143 michael 8059
144 michael 1165 hash_del_client(target_p);
145 michael 7855 strlcpy(target_p->name, new_nick, sizeof(target_p->name));
146 michael 1165 hash_add_client(target_p);
147    
148     watch_check_hash(target_p, RPL_LOGON);
149    
150 michael 8339 fd_note(target_p->connection->fd, "Nick: %s", target_p->name);
151 michael 1165 }
152 michael 1230
153 michael 2820 static struct Message svsnick_msgtab =
154     {
155 michael 5881 .cmd = "SVSNICK",
156     .args_min = 4,
157     .args_max = MAXPARA,
158     .handlers[UNREGISTERED_HANDLER] = m_ignore,
159     .handlers[CLIENT_HANDLER] = m_ignore,
160     .handlers[SERVER_HANDLER] = ms_svsnick,
161     .handlers[ENCAP_HANDLER] = m_ignore,
162     .handlers[OPER_HANDLER] = m_ignore
163 michael 1230 };
164    
165     static void
166     module_init(void)
167     {
168     mod_add_cmd(&svsnick_msgtab);
169     }
170    
171     static void
172     module_exit(void)
173     {
174     mod_del_cmd(&svsnick_msgtab);
175     }
176    
177 michael 2820 struct module module_entry =
178     {
179 michael 1230 .version = "$Revision$",
180     .modinit = module_init,
181     .modexit = module_exit,
182     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision