Hi, * Truls Becken <truls.bec...@gmail.com> [2015-01-27 08:57]: > On Mon, Jan 26, 2015 at 3:23 AM, Troy Sankey <sankey...@gmail.com> wrote: > > If an error occurs changing nick (with /n) then it will become out of > > sync with the server. Here are some of the consequences: > > > > * ii will log outgoing messages with the new nick, but others will > > receive them from the old nick > > * private messaging breaks > > > > Conceivably, this issue is common on large networks where there is a > > high likelihood of nick collisions. I noticed it on my own server where > > the maximum nick length is 9 characters, and I accidentally exceeded > > that. > > > > This patch removes the /n command, making /NICK the only way to change > > the nick. This could make people angry, what do you think? /me doesn't > > think there are many people using ii, so it won't make many people > > angry :-) > > > Alternatively, /n could still send NICK, but not prematurely set the variable.
Thanks for the report, this is definitely a problem. If possible, I'd like to prevent dropping /n mostly for compatibility reasons and making sure that basic IRC functionality is still provided by short commands. What I think may be better would be to only set nick after a successful NICK message was received from the network as Truls suggests. Would you mind testing the attached patch? Cheers Nico -- Nico Golde - XMPP: n...@jabber.ccc.de - GPG: 0xA0A0AAAA
diff --git a/ii.c b/ii.c index d93266c..f52c71c 100644 --- a/ii.c +++ b/ii.c @@ -38,6 +38,7 @@ static time_t last_response; static Channel *channels = NULL; static char *host = "irc.freenode.net"; static char nick[32]; /* might change while running */ +static char _nick[32]; /* might change while running */ static char path[_POSIX_PATH_MAX]; static char message[PIPE_BUF]; /* message buf used for communication */ @@ -261,7 +262,7 @@ static void proc_channels_input(Channel *c, char *buf) { break; case 'n': if(strlen(buf)>=3){ - snprintf(nick, sizeof(nick),"%s", &buf[3]); + snprintf(_nick, sizeof(nick),"%s", &buf[3]); snprintf(message, PIPE_BUF, "NICK %s\r\n", &buf[3]); } break; @@ -357,6 +358,8 @@ static void proc_server_cmd(char *buf) { snprintf(message, PIPE_BUF, "-!- %s changed mode/%s -> %s %s", argv[TOK_NICKSRV], argv[TOK_CMD + 1] ? argv[TOK_CMD + 1] : "" , argv[TOK_CMD + 2]? argv[TOK_CMD + 2] : "", argv[TOK_CMD + 3] ? argv[TOK_CMD + 3] : ""); else if(!strncmp("QUIT", argv[TOK_CMD], 5)) snprintf(message, PIPE_BUF, "-!- %s(%s) has quit \"%s\"", argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_TEXT] ? argv[TOK_TEXT] : ""); + else if(!strncmp("NICK", argv[TOK_CMD], 5) && !strcmp(_nick, argv[TOK_TEXT])) + snprintf(nick, sizeof(nick), _nick); else if(!strncmp("NICK", argv[TOK_CMD], 5)) snprintf(message, PIPE_BUF, "-!- %s changed nick to %s", argv[TOK_NICKSRV], argv[TOK_TEXT]); else if(!strncmp("TOPIC", argv[TOK_CMD], 6))
pgp6Ug8aZTUyh.pgp
Description: PGP signature