# HG changeset patch # User Tero Marttila # Date 1238108494 -7200 # Node ID bc767e01648d9a79af1141cb671cbf82d4ebf0de # Parent d90edc052352e9a422dddf99c92a2f9f3e36dce1 fix a valgrind'd bug with irc_nick_chanflags being given an empty string diff -r d90edc052352 -r bc767e01648d src/irc_chan.c --- a/src/irc_chan.c Fri Mar 27 00:48:12 2009 +0200 +++ b/src/irc_chan.c Fri Mar 27 01:01:34 2009 +0200 @@ -160,6 +160,10 @@ // iterate over each name // XXX: nickflags while ((nickname = strsep(&names, " "))) { + // skip empty token at end + if (strlen(nickname) == 0) + continue; + // parse off the channel flags nickname = irc_nick_chanflags(nickname, chanflags); diff -r d90edc052352 -r bc767e01648d src/irc_proto.c --- a/src/irc_proto.c Fri Mar 27 00:48:12 2009 +0200 +++ b/src/irc_proto.c Fri Mar 27 01:01:34 2009 +0200 @@ -96,7 +96,8 @@ char *cf = chanflags; // consume the chanflags, using strchr to look for the char in the set of chanflags... - while (strchr(IRC_CHANFLAGS, *nick) && (cf < chanflags + IRC_CHANFLAGS_MAX - 1)) + // XXX: error if nickname is empty... + while (*nick && strchr(IRC_CHANFLAGS, *nick) && (cf < chanflags + IRC_CHANFLAGS_MAX - 1)) *cf++ = *nick++; // NUL-terminate chanflags diff -r d90edc052352 -r bc767e01648d src/test.c --- a/src/test.c Fri Mar 27 00:48:12 2009 +0200 +++ b/src/test.c Fri Mar 27 01:01:34 2009 +0200 @@ -764,6 +764,7 @@ { // RPL_NAMREPLY test_sock_push(sock, "353 mynick = %s :mynick userA +userB @userC\r\n", ctx->channel); + test_sock_push(sock, "353 mynick = %s :trailingspace \r\n", ctx->channel); test_sock_push(sock, "366 mynick %s :End of NAMES\r\n", ctx->channel); // XXX: this should be an exclusive test, i.e. these should be the only ones...