ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/branches/1.0.x/src/irc.c
(Generate patch)

Comparing hopm/branches/1.0.x/src/irc.c (file contents):
Revision 5691 by michael, Sat Mar 14 18:50:57 2015 UTC vs.
Revision 5692 by michael, Sat Mar 14 19:03:10 2015 UTC

# Line 60 | Line 60 | static void irc_parse(void);
60  
61   static const struct ChannelConf *get_channel(const char *);
62  
63 < static struct UserInfo *userinfo_create(char *);
63 > static struct UserInfo *userinfo_create(const char *);
64   static void userinfo_free(struct UserInfo *source);
65  
66   static void m_ping(char *[], unsigned int, const char *, const struct UserInfo *);
# Line 587 | Line 587 | get_channel(const char *channel)
587   *    pointer to new UserInfo struct, or NULL if parsing failed
588   */
589   static struct UserInfo *
590 < userinfo_create(char *source)
590 > userinfo_create(const char *source)
591   {
592    struct UserInfo *ret;
593 <  char *nick;
594 <  char *username;
595 <  char *hostname;
596 <  char *tmp;
597 <  int i, len;
598 <
599 <  nick = username = hostname = NULL;
600 <  tmp = xstrdup(source);
601 <  len = strlen(tmp);
593 >  char *nick = NULL;
594 >  char *username = NULL;
595 >  char *hostname = NULL;
596 >  char tmp[MSGLENMAX];
597 >  size_t i, len;
598 >
599 >  len = strlcpy(tmp, source, sizeof(tmp));
600    nick = tmp;
601  
602    for (i = 0; i < len; ++i)
# Line 616 | Line 614 | userinfo_create(char *source)
614      }
615    }
616  
617 <  if (nick == NULL || username == NULL || hostname == NULL)
620 <  {
621 <    xfree(tmp);
617 >  if (username == NULL || hostname == NULL)
618      return NULL;
623  }
619  
620    ret = xcalloc(sizeof *ret);
621    ret->irc_nick     = xstrdup(nick);
622    ret->irc_username = xstrdup(username);
623    ret->irc_hostname = xstrdup(hostname);
624  
630  xfree(tmp);
631
625    return ret;
626   };
627  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines