Fix parsing of MONITOR responses

Fixes #1157
This commit is contained in:
TingPing 2014-09-27 13:11:21 -04:00
parent e8fb2dde56
commit abaed2bda4
1 changed files with 8 additions and 20 deletions

View File

@ -293,26 +293,20 @@ notify_set_offline_list (server * serv, char *users, int quiet,
struct notify_per_server *servnot; struct notify_per_server *servnot;
char nick[NICKLEN]; char nick[NICKLEN];
char *token, *chr; char *token, *chr;
int pos;
token = strtok (users, ","); token = strtok (users, ",");
while (token != NULL) while (token != NULL)
{ {
chr = strchr (token, '!'); chr = strchr (token, '!');
if (!chr) if (chr != NULL)
goto end; *chr = '\0';
pos = chr - token; g_strlcpy (nick, token, sizeof(nick));
if (pos + 1 >= sizeof(nick))
goto end;
memset (nick, 0, sizeof(nick));
strncpy (nick, token, pos);
servnot = notify_find (serv, nick); servnot = notify_find (serv, nick);
if (servnot) if (servnot)
notify_announce_offline (serv, servnot, nick, quiet, tags_data); notify_announce_offline (serv, servnot, nick, quiet, tags_data);
end:
token = strtok (NULL, ","); token = strtok (NULL, ",");
} }
} }
@ -324,26 +318,20 @@ notify_set_online_list (server * serv, char *users,
struct notify_per_server *servnot; struct notify_per_server *servnot;
char nick[NICKLEN]; char nick[NICKLEN];
char *token, *chr; char *token, *chr;
int pos;
token = strtok (users, ","); token = strtok (users, ",");
while (token != NULL) while (token != NULL)
{ {
chr = strchr (token, '!'); chr = strchr (token, '!');
if (!chr) if (chr != NULL)
goto end; *chr = '\0';
pos = chr - token; g_strlcpy (nick, token, sizeof(nick));
if (pos + 1 >= sizeof(nick))
goto end;
memset (nick, 0, sizeof(nick));
strncpy (nick, token, pos);
servnot = notify_find (serv, nick); servnot = notify_find (serv, nick);
if (servnot) if (servnot)
notify_announce_online (serv, servnot, nick, tags_data); notify_announce_online (serv, servnot, nick, tags_data);
end:
token = strtok (NULL, ","); token = strtok (NULL, ",");
} }
} }