ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/user.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/user.c (file contents):
Revision 4709 by michael, Mon Oct 6 16:52:29 2014 UTC vs.
Revision 5805 by michael, Tue Apr 21 21:49:58 2015 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2014 ircd-hybrid development team
4 > *  Copyright (c) 1997-2015 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 19 | Line 19
19   *  USA
20   */
21  
22 < /*! \file s_user.c
22 > /*! \file user.c
23   * \brief User related functions.
24   * \version $Id$
25   */
# Line 65 | Line 65 | struct Isupport
65   static dlink_list support_list;
66   static dlink_list support_list_lines;
67  
68 < /* memory is cheap. map 0-255 to equivalent mode */
69 < const unsigned int user_modes[256] =
68 > const struct user_modes *umode_map[256];
69 > const struct user_modes  umode_tab[] =
70   {
71 <  /* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */
72 <  /* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */
73 <  /* 0x20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x2F */
74 <  /* 0x30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x3F */
75 <  0,                  /* @ */
76 <  0,                  /* A */
77 <  0,                  /* B */
78 <  0,                  /* C */
79 <  UMODE_DEAF,         /* D */
80 <  0,                  /* E */
81 <  UMODE_FARCONNECT,   /* F */
82 <  UMODE_SOFTCALLERID, /* G */
83 <  UMODE_HIDDEN,       /* H */
84 <  0,                  /* I */
85 <  0,                  /* J */
86 <  0,                  /* K */
87 <  0,                  /* L */
88 <  0,                  /* M */
89 <  0,                  /* N */
90 <  0,                  /* O */
91 <  0,                  /* P */
92 <  0,                  /* Q */
93 <  UMODE_REGONLY,      /* R */
94 <  UMODE_SSL,          /* S */
95 <  0,                  /* T */
96 <  0,                  /* U */
97 <  0,                  /* V */
98 <  UMODE_WEBIRC,       /* W */
99 <  0,                  /* X */
100 <  0,                  /* Y */
101 <  0,                  /* Z 0x5A */
102 <  0, 0, 0, 0, 0,      /* 0x5F   */
103 <  0,                  /* 0x60   */
104 <  UMODE_ADMIN,        /* a */
105 <  UMODE_BOTS,         /* b */
106 <  UMODE_CCONN,        /* c */
107 <  UMODE_DEBUG,        /* d */
108 <  UMODE_EXTERNAL,     /* e */
109 <  UMODE_FULL,         /* f */
110 <  UMODE_CALLERID,     /* g */
111 <  0,                  /* h */
112 <  UMODE_INVISIBLE,    /* i */
113 <  UMODE_REJ,          /* j */
114 <  UMODE_SKILL,        /* k */
115 <  UMODE_LOCOPS,       /* l */
116 <  0,                  /* m */
117 <  UMODE_NCHANGE,      /* n */
118 <  UMODE_OPER,         /* o */
119 <  UMODE_HIDECHANS,    /* p */
120 <  UMODE_HIDEIDLE,     /* q */
121 <  UMODE_REGISTERED,   /* r */
122 <  UMODE_SERVNOTICE,   /* s */
123 <  0,                  /* t */
124 <  UMODE_UNAUTH,       /* u */
125 <  0,                  /* v */
126 <  UMODE_WALLOP,       /* w */
127 <  UMODE_HIDDENHOST,   /* x */
128 <  UMODE_SPY,          /* y */
129 <  0,                  /* z      0x7A */
130 <  0,0,0,0,0,          /* 0x7B - 0x7F */
131 <
132 <  /* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x8F */
133 <  /* 0x90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9F */
134 <  /* 0xA0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xAF */
135 <  /* 0xB0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xBF */
136 <  /* 0xC0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xCF */
137 <  /* 0xD0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xDF */
138 <  /* 0xE0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xEF */
139 <  /* 0xF0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0  /* 0xFF */
71 >  { 'D', UMODE_DEAF         },
72 >  { 'F', UMODE_FARCONNECT   },
73 >  { 'G', UMODE_SOFTCALLERID },
74 >  { 'H', UMODE_HIDDEN       },
75 >  { 'R', UMODE_REGONLY      },
76 >  { 'S', UMODE_SSL          },
77 >  { 'W', UMODE_WEBIRC       },
78 >  { 'a', UMODE_ADMIN        },
79 >  { 'b', UMODE_BOTS         },
80 >  { 'c', UMODE_CCONN        },
81 >  { 'd', UMODE_DEBUG        },
82 >  { 'e', UMODE_EXTERNAL     },
83 >  { 'f', UMODE_FULL         },
84 >  { 'g', UMODE_CALLERID     },
85 >  { 'i', UMODE_INVISIBLE    },
86 >  { 'j', UMODE_REJ          },
87 >  { 'k', UMODE_SKILL        },
88 >  { 'l', UMODE_LOCOPS       },
89 >  { 'n', UMODE_NCHANGE      },
90 >  { 'o', UMODE_OPER         },
91 >  { 'p', UMODE_HIDECHANS    },
92 >  { 'q', UMODE_HIDEIDLE     },
93 >  { 'r', UMODE_REGISTERED   },
94 >  { 's', UMODE_SERVNOTICE   },
95 >  { 'u', UMODE_UNAUTH       },
96 >  { 'w', UMODE_WALLOP       },
97 >  { 'x', UMODE_HIDDENHOST   },
98 >  { 'y', UMODE_SPY          },
99 >  { '\0', 0 }
100   };
101  
102   void
103 < assemble_umode_buffer(void)
103 > user_usermodes_init(void)
104   {
145  unsigned int idx = 0;
105    char *umode_buffer_ptr = umode_buffer;
106  
107 <  for (; idx < (sizeof(user_modes) / sizeof(user_modes[0])); ++idx)
108 <    if (user_modes[idx])
109 <      *umode_buffer_ptr++ = idx;
107 >  for (const struct user_modes *tab = umode_tab; tab->c; ++tab)
108 >  {
109 >    umode_map[tab->c] = tab;
110 >    *umode_buffer_ptr++ = tab->c;
111 >  }
112  
113    *umode_buffer_ptr = '\0';
114   }
# Line 162 | Line 123 | void
123   show_lusers(struct Client *source_p)
124   {
125    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
126 <    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi),
126 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total - Count.invisi),
127                         Count.invisi, dlink_list_length(&global_server_list));
128    else
129 <    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT,
130 <                       (Count.total - Count.invisi), Count.invisi, 1);
129 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total - Count.invisi),
130 >                       Count.invisi, 1);
131  
132    if (Count.oper)
133      sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper);
# Line 210 | Line 171 | show_lusers(struct Client *source_p)
171   void
172   show_isupport(struct Client *source_p)
173   {
174 <  const dlink_node *ptr = NULL;
174 >  const dlink_node *node = NULL;
175  
176 <  DLINK_FOREACH(ptr, support_list_lines.head)
177 <    sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data);
176 >  DLINK_FOREACH(node, support_list_lines.head)
177 >    sendto_one_numeric(source_p, &me, RPL_ISUPPORT, node->data);
178   }
179  
180  
# Line 232 | Line 193 | report_and_set_user_flags(struct Client
193    if (IsConfDoSpoofIp(conf))
194      sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats.");
195  
196 <  /* If this user is in the exception class, Set it "E lined" */
196 >  /* If this user is in the exception class, set it "E lined" */
197    if (IsConfExemptKline(conf))
198    {
199      SetExemptKline(source_p);
200      sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats.");
201    }
202  
242  /*
243   * The else here is to make sure that G line exempt users
244   * do not get noticed twice.
245   */
246  else if (IsConfExemptGline(conf))
247  {
248    SetExemptGline(source_p);
249    sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats.");
250  }
251
203    if (IsConfExemptResv(conf))
204    {
205      SetExemptResv(source_p);
# Line 281 | Line 232 | report_and_set_user_flags(struct Client
232   static void
233   introduce_client(struct Client *source_p)
234   {
235 <  dlink_node *ptr = NULL;
235 >  dlink_node *node = NULL;
236    char ubuf[IRCD_BUFSIZE] = "";
237  
238    if (MyClient(source_p))
# Line 297 | Line 248 | introduce_client(struct Client *source_p
248      ubuf[1] = '\0';
249    }
250  
251 <  DLINK_FOREACH(ptr, local_server_list.head)
251 >  DLINK_FOREACH(node, local_server_list.head)
252    {
253 <    struct Client *server = ptr->data;
253 >    struct Client *server = node->data;
254  
255      if (server == source_p->from)
256        continue;
257  
258      if (IsCapable(server, CAP_SVS))
259 <      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
259 >      sendto_one(server, ":%s UID %s %u %lu %s %s %s %s %s %s :%s",
260                   source_p->servptr->id,
261                   source_p->name, source_p->hopcount+1,
262                   (unsigned long)source_p->tsinfo,
263                   ubuf, source_p->username, source_p->host,
264 <                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
265 <                 "0" : source_p->sockhost, source_p->id,
315 <                 source_p->svid,
264 >                 source_p->sockhost, source_p->id,
265 >                 source_p->account,
266                   source_p->info);
267      else
268 <      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
268 >      sendto_one(server, ":%s UID %s %u %lu %s %s %s %s %s :%s",
269                   source_p->servptr->id,
270                   source_p->name, source_p->hopcount+1,
271                   (unsigned long)source_p->tsinfo,
272                   ubuf, source_p->username, source_p->host,
273 <                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
324 <                 "0" : source_p->sockhost, source_p->id, source_p->info);
273 >                 source_p->sockhost, source_p->id, source_p->info);
274  
275      if (!EmptyString(source_p->certfp))
276        sendto_one(server, ":%s CERTFP %s", source_p->id, source_p->certfp);
# Line 375 | Line 324 | static int
324   check_xline(struct Client *source_p)
325   {
326    struct MaskItem *conf = NULL;
378  const char *reason = NULL;
327  
328    if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0)))
329    {
330      ++conf->count;
383
384    if (conf->reason)
385      reason = conf->reason;
386    else
387      reason = CONF_NOREASON;
388
331      sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
332                           "X-line Rejecting [%s] [%s], user %s [%s]",
333 <                         source_p->info, reason,
333 >                         source_p->info, conf->reason,
334                           get_client_name(source_p, HIDE_IP),
335                           source_p->sockhost);
336  
# Line 413 | Line 355 | register_local_user(struct Client *sourc
355  
356    assert(source_p == source_p->from);
357    assert(MyConnect(source_p));
358 +  assert(IsUnknown(source_p));
359    assert(!source_p->connection->registration);
360  
418  ClearCap(source_p, CAP_TS6);
419
361    if (ConfigGeneral.ping_cookie)
362    {
363      if (!IsPingSent(source_p) && !source_p->connection->random_ping)
# Line 425 | Line 366 | register_local_user(struct Client *sourc
366          source_p->connection->random_ping = genrand_int32();
367        while (!source_p->connection->random_ping);
368  
369 <      sendto_one(source_p, "PING :%u",
429 <                 source_p->connection->random_ping);
369 >      sendto_one(source_p, "PING :%u", source_p->connection->random_ping);
370        SetPingSent(source_p);
371        return;
372      }
# Line 446 | Line 386 | register_local_user(struct Client *sourc
386    {
387      sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal "
388                        "character in your hostname");
389 <    strlcpy(source_p->host, source_p->sockhost,
450 <            sizeof(source_p->host));
389 >    strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
390    }
391  
392    conf = source_p->connection->confs.head->data;
# Line 493 | Line 432 | register_local_user(struct Client *sourc
432  
433    /*
434     * Don't free source_p->connection->password here - it can be required
435 <   * by masked /stats I if there are auth{} blocks with need_password = no;
435 >   * by masked /stats I if there are auth {} blocks with need_password = no;
436     * --adx
437     */
438  
# Line 513 | Line 452 | register_local_user(struct Client *sourc
452     * probably be just a percentage of the MAXCLIENTS...
453     *   -Taner
454     */
455 <  if ((Count.local >= ConfigServerInfo.max_clients + MAX_BUFFER) ||
456 <      (Count.local >= ConfigServerInfo.max_clients && !IsExemptLimits(source_p)))
455 >  if ((Count.local >= GlobalSetOptions.maxclients + MAX_BUFFER) ||
456 >      (Count.local >= GlobalSetOptions.maxclients && !IsExemptLimits(source_p)))
457    {
458      sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
459                           "Too many clients, rejecting %s[%s].",
# Line 549 | Line 488 | register_local_user(struct Client *sourc
488    sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE,
489                         "Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>",
490                         source_p->name, source_p->username, source_p->host,
491 <                       ConfigGeneral.hide_spoof_ips && IsIPSpoof(source_p) ?
553 <                       "255.255.255.255" : source_p->sockhost,
491 >                       source_p->sockhost,
492                         get_client_class(&source_p->connection->confs),
493                         source_p->info, source_p->id);
494  
# Line 614 | Line 552 | register_remote_user(struct Client *sour
552                           source_p->host, source_p->servptr->name,
553                           target_p->name, target_p->from->name);
554      sendto_one(source_p->from,
555 <               ":%s KILL %s :%s (NICK from wrong direction (%s != %s))",
555 >               ":%s KILL %s :%s (UID from wrong direction (%s != %s))",
556                 me.id, source_p->id, me.name, source_p->servptr->name,
557                 target_p->from->name);
558  
559      AddFlag(source_p, FLAGS_KILLED);
560 <    exit_client(source_p, "USER server wrong direction");
560 >    exit_client(source_p, "UID server wrong direction");
561      return;
562    }
563  
# Line 641 | Line 579 | register_remote_user(struct Client *sour
579  
580    if (HasFlag(source_p->servptr, FLAGS_EOB))
581      sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE,
582 <                         "Client connecting at %s: %s (%s@%s) [%s] <%s>",
582 >                         "Client connecting at %s: %s (%s@%s) [%s] [%s] <%s>",
583                           source_p->servptr->name,
584                           source_p->name, source_p->username, source_p->host,
585 <                         source_p->info, source_p->id);
585 >                         source_p->sockhost, source_p->info, source_p->id);
586  
587    introduce_client(source_p);
588   }
# Line 742 | Line 680 | valid_nickname(const char *nickname, con
680   {
681    const char *p = nickname;
682  
683 <  assert(nickname && *nickname);
683 >  assert(p);
684  
685    /*
686     * Nicks can't start with a digit or - or be 0 length.
# Line 779 | Line 717 | send_umode(struct Client *client_p, stru
717     * Build a string in umode_buf to represent the change in the user's
718     * mode between the new (source_p->umodes) and 'old'.
719     */
720 <  for (unsigned int i = 0; i < 128; ++i)
720 >  for (const struct user_modes *tab = umode_tab; tab->c; ++tab)
721    {
722 <    unsigned int flag = user_modes[i];
785 <
786 <    if (!flag)
787 <      continue;
788 <
789 <    if ((flag & old) && !HasUMode(source_p, flag))
722 >    if ((tab->flag & old) && !HasUMode(source_p, tab->flag))
723      {
724        if (what == MODE_DEL)
725 <        *m++ = (char)i;
725 >        *m++ = tab->c;
726        else
727        {
728          what = MODE_DEL;
729          *m++ = '-';
730 <        *m++ = (char)i;
730 >        *m++ = tab->c;
731        }
732      }
733 <    else if (!(flag & old) && HasUMode(source_p, flag))
733 >    else if (!(tab->flag & old) && HasUMode(source_p, tab->flag))
734      {
735        if (what == MODE_ADD)
736 <        *m++ = (char)i;
736 >        *m++ = tab->c;
737        else
738        {
739          what = MODE_ADD;
740          *m++ = '+';
741 <        *m++ = (char)i;
741 >        *m++ = tab->c;
742        }
743      }
744    }
# Line 832 | Line 765 | send_umode_out(struct Client *source_p,
765    send_umode(MyClient(source_p) ? source_p : NULL, source_p, old, buf);
766  
767    if (buf[0])
768 <    sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s",
768 >    sendto_server(source_p, 0, 0, ":%s MODE %s :%s",
769                    source_p->id, source_p->id, buf);
770   }
771  
772   void
773   user_set_hostmask(struct Client *target_p, const char *hostname, const int what)
774   {
775 <  dlink_node *ptr = NULL;
775 >  dlink_node *node = NULL;
776  
777    if (!strcmp(target_p->host, hostname))
778      return;
# Line 848 | Line 781 | user_set_hostmask(struct Client *target_
781    {
782      case MODE_ADD:
783        AddUMode(target_p, UMODE_HIDDENHOST);
851      AddFlag(target_p, FLAGS_IP_SPOOFING);
784        break;
785      case MODE_DEL:
786        DelUMode(target_p, UMODE_HIDDENHOST);
855
856      if (!HasFlag(target_p, FLAGS_AUTH_SPOOF))
857        DelFlag(target_p, FLAGS_IP_SPOOFING);
787        break;
788      default: return;
789    }
# Line 880 | Line 809 | user_set_hostmask(struct Client *target_
809    if (!ConfigGeneral.cycle_on_host_change)
810      return;
811  
812 <  DLINK_FOREACH(ptr, target_p->channel.head)
812 >  DLINK_FOREACH(node, target_p->channel.head)
813    {
814      char modebuf[4], nickbuf[NICKLEN * 3 + 3] = "";
815      char *p = modebuf;
816      int len = 0;
817 <    const struct Membership *ms = ptr->data;
817 >    const struct Membership *member = node->data;
818  
819 <    if (has_member_flags(ms, CHFL_CHANOP))
819 >    if (has_member_flags(member, CHFL_CHANOP))
820      {
821        *p++ = 'o';
822        len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
823      }
824  
825 <    if (has_member_flags(ms, CHFL_HALFOP))
825 >    if (has_member_flags(member, CHFL_HALFOP))
826      {
827        *p++ = 'h';
828        len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
829      }
830  
831 <    if (has_member_flags(ms, CHFL_VOICE))
831 >    if (has_member_flags(member, CHFL_VOICE))
832      {
833        *p++ = 'v';
834        len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name);
# Line 907 | Line 836 | user_set_hostmask(struct Client *target_
836  
837      *p = '\0';
838  
839 <    sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s!%s@%s JOIN :%s",
840 <                                target_p->name, target_p->username, target_p->host,
841 <                                ms->chptr->name);
839 >
840 >    sendto_channel_local_butone(target_p, CAP_EXTENDED_JOIN, 0, member->chptr, ":%s!%s@%s JOIN %s %s :%s",
841 >                                target_p->name, target_p->username,
842 >                                target_p->host, member->chptr->name,
843 >                                (!IsDigit(target_p->account[0]) && target_p->account[0] != '*') ? target_p->account : "*",
844 >                                target_p->info);
845 >    sendto_channel_local_butone(target_p, 0, CAP_EXTENDED_JOIN, member->chptr, ":%s!%s@%s JOIN :%s",
846 >                                target_p->name, target_p->username,
847 >                                target_p->host, member->chptr->name);
848 >
849      if (nickbuf[0])
850 <      sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s MODE %s +%s %s",
851 <                                  target_p->servptr->name, ms->chptr->name,
850 >      sendto_channel_local_butone(target_p, 0, 0, member->chptr, ":%s MODE %s +%s %s",
851 >                                  target_p->servptr->name, member->chptr->name,
852                                    modebuf, nickbuf);
853  
854    }
# Line 932 | Line 868 | void
868   oper_up(struct Client *source_p)
869   {
870    const unsigned int old = source_p->umodes;
871 <  const struct MaskItem *conf = source_p->connection->confs.head->data;
871 >  const struct MaskItem *const conf = source_p->connection->confs.head->data;
872  
873    assert(source_p->connection->confs.head);
874  
# Line 957 | Line 893 | oper_up(struct Client *source_p)
893    if (HasOFlag(source_p, OPER_FLAG_ADMIN))
894      AddUMode(source_p, UMODE_ADMIN);
895  
896 +  if (!EmptyString(conf->whois))
897 +  {
898 +    client_attach_svstag(source_p, RPL_WHOISOPERATOR, "+", conf->whois);
899 +    sendto_server(source_p, 0, 0, ":%s SVSTAG %s %lu %u + :%s",
900 +                  me.id, source_p->id, (unsigned long)source_p->tsinfo,
901 +                  RPL_WHOISOPERATOR, conf->whois);
902 +  }
903 +
904    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator",
905                         get_oper_name(source_p));
906 <  sendto_server(NULL, NOCAPS, NOCAPS, ":%s GLOBOPS :%s is now an operator",
906 >  sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s is now an operator",
907                  me.id, get_oper_name(source_p));
908    send_umode_out(source_p, old);
909    sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
# Line 984 | Line 928 | valid_sid(const char *sid)
928   * inputs       - NONE
929   * output       - NONE
930   * side effects - new_uid is filled in with server id portion (sid)
931 < *                (first 3 bytes) or defaulted to 'A'.
932 < *                Rest is filled in with 'A'
931 > *                (first 3 bytes). Rest is filled in with '9'.
932 > *
933 > * NOTE: this function assumes that 'ConfigServerInfo.sid' has been set to a proper value
934   */
935   void
936   init_uid(void)
937   {
938 <  memset(new_uid, 0, sizeof(new_uid));
994 <
995 <  if (!EmptyString(ConfigServerInfo.sid))
996 <    strlcpy(new_uid, ConfigServerInfo.sid, sizeof(new_uid));
997 <
998 <  for (unsigned int i = 0; i < IRC_MAXSID; ++i)
999 <    if (new_uid[i] == '\0')
1000 <      new_uid[i] = 'A';
1001 <
1002 <  /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1003 <  memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
938 >  snprintf(new_uid, sizeof(new_uid), "%s999999", ConfigServerInfo.sid);
939   }
940  
941   /*
# Line 1014 | Line 949 | init_uid(void)
949   static void
950   add_one_to_uid(unsigned int i)
951   {
952 <  if (i != IRC_MAXSID)  /* Not reached server SID portion yet? */
952 >  if (i < IRC_MAXSID)
953 >    return;
954 >
955 >  if (new_uid[i] == 'Z')
956 >    new_uid[i] = '0';
957 >  else if (new_uid[i] == '9')
958    {
959 <    if (new_uid[i] == 'Z')
960 <      new_uid[i] = '0';
1021 <    else if (new_uid[i] == '9')
1022 <    {
1023 <      new_uid[i] = 'A';
1024 <      add_one_to_uid(i - 1);
1025 <    }
1026 <    else
1027 <      ++new_uid[i];
959 >    new_uid[i] = 'A';
960 >    add_one_to_uid(i - 1);
961    }
962    else
963 <  {
1031 <    /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1032 <    if (new_uid[i] == 'Z')
1033 <      memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1034 <    else
1035 <      ++new_uid[i];
1036 <  }
963 >    ++new_uid[i];
964   }
965  
966   /*
# Line 1067 | Line 994 | init_isupport(void)
994    add_isupport("MODES", NULL, MAXMODEPARAMS);
995    add_isupport("PREFIX", "(ohv)@%+", -1);
996    add_isupport("STATUSMSG", "@%+", -1);
997 <  add_isupport("EXCEPTS", "e", -1);
998 <  add_isupport("INVEX", "I", -1);
997 >  add_isupport("EXCEPTS", NULL, -1);
998 >  add_isupport("INVEX", NULL, -1);
999   }
1000  
1001   /*
# Line 1083 | Line 1010 | init_isupport(void)
1010   void
1011   add_isupport(const char *name, const char *options, int n)
1012   {
1013 <  dlink_node *ptr;
1013 >  dlink_node *node = NULL;
1014    struct Isupport *support = NULL;
1015  
1016 <  DLINK_FOREACH(ptr, support_list.head)
1016 >  DLINK_FOREACH(node, support_list.head)
1017    {
1018 <    support = ptr->data;
1018 >    support = node->data;
1019      if (irccmp(support->name, name) == 0)
1020      {
1021        MyFree(support->name);
# Line 1097 | Line 1024 | add_isupport(const char *name, const cha
1024      }
1025    }
1026  
1027 <  if (ptr == NULL)
1027 >  if (node == NULL)
1028    {
1029      support = MyCalloc(sizeof(*support));
1030      dlinkAddTail(support, &support->node, &support_list);
# Line 1121 | Line 1048 | add_isupport(const char *name, const cha
1048   void
1049   delete_isupport(const char *name)
1050   {
1051 <  dlink_node *ptr;
1125 <  struct Isupport *support;
1051 >  dlink_node *node = NULL;
1052  
1053 <  DLINK_FOREACH(ptr, support_list.head)
1053 >  DLINK_FOREACH(node, support_list.head)
1054    {
1055 <    support = ptr->data;
1055 >    struct Isupport *support = node->data;
1056 >
1057      if (irccmp(support->name, name) == 0)
1058      {
1059 <      dlinkDelete(ptr, &support_list);
1059 >      dlinkDelete(node, &support_list);
1060        MyFree(support->name);
1061        MyFree(support->options);
1062        MyFree(support);
# Line 1152 | Line 1079 | rebuild_isupport_message_line(void)
1079   {
1080    char isupportbuffer[IRCD_BUFSIZE];
1081    char *p = isupportbuffer;
1082 <  dlink_node *ptr = NULL, *ptr_next = NULL;
1082 >  dlink_node *node = NULL, *node_next = NULL;
1083    int n = 0;
1084    int tokens = 0;
1085    size_t len = 0;
1086    size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT));
1087  
1088 <  DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head)
1088 >  DLINK_FOREACH_SAFE(node, node_next, support_list_lines.head)
1089    {
1090 <    dlinkDelete(ptr, &support_list_lines);
1091 <    MyFree(ptr->data);
1092 <    free_dlink_node(ptr);
1090 >    dlinkDelete(node, &support_list_lines);
1091 >    MyFree(node->data);
1092 >    free_dlink_node(node);
1093    }
1094  
1095 <  DLINK_FOREACH(ptr, support_list.head)
1095 >  DLINK_FOREACH(node, support_list.head)
1096    {
1097 <    struct Isupport *support = ptr->data;
1097 >    struct Isupport *support = node->data;
1098  
1099      p += (n = sprintf(p, "%s", support->name));
1100      len += n;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)