/[svn]/ircd-hybrid-8/modules/core/m_server.c
ViewVC logotype

Diff of /ircd-hybrid-8/modules/core/m_server.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1532 by michael, Sun Sep 16 10:27:19 2012 UTC revision 1533 by michael, Sun Sep 23 13:04:45 2012 UTC
# Line 39  Line 39 
39  #include "modules.h"  #include "modules.h"
40    
41    
42  static void set_server_gecos(struct Client *, char *);  static void set_server_gecos(struct Client *, const char *);
43    
44  /* mr_server()  /* mr_server()
45   *  parv[0] = sender prefix   *  parv[0] = sender prefix
# Line 51  static void Line 51  static void
51  mr_server(struct Client *client_p, struct Client *source_p,  mr_server(struct Client *client_p, struct Client *source_p,
52            int parc, char *parv[])            int parc, char *parv[])
53  {  {
   char info[REALLEN + 1];  
54    char *name;    char *name;
55    struct Client *target_p;    struct Client *target_p;
56    int hop;    int hop;
# Line 65  mr_server(struct Client *client_p, struc Line 64  mr_server(struct Client *client_p, struc
64    
65    name = parv[1];    name = parv[1];
66    hop  = atoi(parv[2]);    hop  = atoi(parv[2]);
   strlcpy(info, parv[3], sizeof(info));  
67    
68    /*    /*
69     * Reject a direct nonTS server connection if we're TS_ONLY -orabidoo     * Reject a direct nonTS server connection if we're TS_ONLY -orabidoo
# Line 183  mr_server(struct Client *client_p, struc Line 181  mr_server(struct Client *client_p, struc
181     * connect{} block in client_p->name     * connect{} block in client_p->name
182     */     */
183    strlcpy(client_p->name, name, sizeof(client_p->name));    strlcpy(client_p->name, name, sizeof(client_p->name));
184    set_server_gecos(client_p, info);    set_server_gecos(client_p, parv[3]);
185    client_p->hopcount = hop;    client_p->hopcount = hop;
186    server_estab(client_p);    server_estab(client_p);
187  }  }
# Line 198  static void Line 196  static void
196  ms_server(struct Client *client_p, struct Client *source_p,  ms_server(struct Client *client_p, struct Client *source_p,
197            int parc, char *parv[])            int parc, char *parv[])
198  {  {
   char info[REALLEN + 1];  
199    char *name;    char *name;
200    struct Client *target_p;    struct Client *target_p;
201    struct AccessItem *aconf;    struct AccessItem *aconf;
# Line 219  ms_server(struct Client *client_p, struc Line 216  ms_server(struct Client *client_p, struc
216    
217    name = parv[1];    name = parv[1];
218    hop  = atoi(parv[2]);    hop  = atoi(parv[2]);
   strlcpy(info, parv[3], sizeof(info));  
219    
220    if (!valid_servname(name))    if (!valid_servname(name))
221    {    {
# Line 354  ms_server(struct Client *client_p, struc Line 350  ms_server(struct Client *client_p, struc
350    
351    strlcpy(target_p->name, name, sizeof(target_p->name));    strlcpy(target_p->name, name, sizeof(target_p->name));
352    
353    set_server_gecos(target_p, info);    set_server_gecos(target_p, parv[3]);
354    SetServer(target_p);    SetServer(target_p);
355    
356    if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(SERVICE_TYPE, target_p->name, NULL, NULL, 0))    if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(SERVICE_TYPE, target_p->name, NULL, NULL, 0))
# Line 386  static void Line 382  static void
382  ms_sid(struct Client *client_p, struct Client *source_p,  ms_sid(struct Client *client_p, struct Client *source_p,
383         int parc, char *parv[])         int parc, char *parv[])
384  {  {
   char info[REALLEN + 1];  
385    struct Client *target_p;    struct Client *target_p;
386    struct AccessItem *aconf = NULL;    struct AccessItem *aconf = NULL;
387    int hlined = 0;    int hlined = 0;
# Line 405  ms_sid(struct Client *client_p, struct C Line 400  ms_sid(struct Client *client_p, struct C
400    }    }
401    
402    hop = atoi(parv[2]);    hop = atoi(parv[2]);
   strlcpy(info, parv[4], sizeof(info));  
403    
404    if (!valid_servname(parv[1]))    if (!valid_servname(parv[1]))
405    {    {
# Line 546  ms_sid(struct Client *client_p, struct C Line 540  ms_sid(struct Client *client_p, struct C
540    strlcpy(target_p->name, parv[1], sizeof(target_p->name));    strlcpy(target_p->name, parv[1], sizeof(target_p->name));
541    strlcpy(target_p->id, parv[3], sizeof(target_p->id));    strlcpy(target_p->id, parv[3], sizeof(target_p->id));
542    
543    set_server_gecos(target_p, info);    set_server_gecos(target_p, parv[4]);
544    SetServer(target_p);    SetServer(target_p);
545    
546    if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(SERVICE_TYPE, target_p->name, NULL, NULL, 0))    if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(SERVICE_TYPE, target_p->name, NULL, NULL, 0))
# Line 578  ms_sid(struct Client *client_p, struct C Line 572  ms_sid(struct Client *client_p, struct C
572   * side effects - servers gecos field is set   * side effects - servers gecos field is set
573   */   */
574  static void  static void
575  set_server_gecos(struct Client *client_p, char *info)  set_server_gecos(struct Client *client_p, const char *info)
576  {  {
577    /* check the info for [IP] */    const char *s = info;
   if (info[0])  
   {  
     char *p;  
     char *s;  
     char *t;  
       
     s = info;  
       
     /* we should only check the first word for an ip */  
     if ((p = strchr(s, ' ')) != NULL)  
       *p = '\0';  
         
     /* check for a ] which would symbolise an [IP] */  
     if ((t = strchr(s, ']')) != NULL)  
     {  
       /* set s to after the first space */  
       if (p)  
         s = ++p;  
       else  
         s = NULL;  
     }  
     /* no ], put the space back */  
     else if (p)  
       *p = ' ';  
   
     /* p may have been set to a trailing space, so check s exists and that  
      * it isnt \0 */  
     if (s && (*s != '\0'))  
     {  
       /* a space? if not (H) could be the last part of info.. */  
       if ((p = strchr(s, ' ')))  
         *p = '\0';  
         
       /* check for (H) which is a hidden server */  
       if (!strcmp(s, "(H)"))  
       {  
         SetHidden(client_p);  
578    
579          /* if there was no space.. theres nothing to set info to */    /* check for (H) which is a hidden server */
580          if (p)    if (!strncmp(s, "(H) ", 4))
581            s = ++p;    {
582          else      SetHidden(client_p);
583            s = NULL;      s = s + 4;
       }  
       else if (p)  
         *p = ' ';  
   
       /* if there was a trailing space, s could point to \0, so check */  
       if (s && (*s != '\0'))  
         strlcpy(client_p->info, s, sizeof(client_p->info));  
       else  
         strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));  
     }  
     else  
       strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));  
584    }    }
585    
586      if (!EmptyString(s))
587        strlcpy(client_p->info, s, sizeof(client_p->info));
588    else    else
589      strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));      strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
590  }  }

Legend:
Removed from v.1532  
changed lines
  Added in v.1533

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28