Index: s_serv.c =================================================================== RCS file: /usr/local/repository/irc/ircd/s_serv.c,v retrieving revision 1.65.2.11 retrieving revision 1.65.2.13 diff -u -r1.65.2.11 -r1.65.2.13 --- s_serv.c 2004/02/26 13:28:41 1.65.2.11 +++ s_serv.c 2004/03/01 18:00:33 1.65.2.13 @@ -22,7 +22,7 @@ */ #ifndef lint -static char rcsid[] = "@(#)$Id: s_serv.c,v 1.65.2.11 2004/02/26 13:28:41 chopin Exp $"; +static char rcsid[] = "@(#)$Id: s_serv.c,v 1.65.2.13 2004/03/01 18:00:33 chopin Exp $"; #endif #include "os.h" @@ -123,7 +123,8 @@ Reg aConfItem *aconf; char *server; Reg aClient *acptr; - char *comment = (parc > 2 && parv[2]) ? parv[2] : cptr->name; + char *comment = (parc > 2 && parv[2]) ? parv[2] : "no reason"; + static char comment2[TOPICLEN+1]; if (parc > 1) { @@ -212,12 +213,18 @@ } if (MyPerson(sptr)) { - char bufn[HOSTLEN+7]; + int k=TOPICLEN-strlen(sptr->name)-7; - sprintf(bufn, " (by %s)", sptr->name); - if (strlen(comment) > TOPICLEN) - comment[TOPICLEN] = '\0'; - strcat(comment, bufn); + /* Shorten original comment, should it be too long. */ + if (strlen(comment) > k) + { + comment[k] = '\0'; + } + /* As we change comment, we have to copy, who knows what + ** parv[2] can overwrite. */ + comment2[0] = '\0'; + sprintf(comment2, "%s (by %s)", comment, sptr->name); + comment = comment2; } if (!MyConnect(acptr) && (cptr != acptr->from)) {