summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-09-27 13:11:21 -0400
committerTingPing <tingping@tingping.se>2014-09-27 13:11:21 -0400
commitabaed2bda49769ef74ffb9ad316f7a8969ac3465 (patch)
tree50f8898e31c03653a45d847067f1054a2b3834be /src
parente8fb2dde56e93c1c2641ae99f8b1988352270f55 (diff)
Fix parsing of MONITOR responses
Fixes #1157
Diffstat (limited to 'src')
-rw-r--r--src/common/notify.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/common/notify.c b/src/common/notify.c
index 80853ecb..bf80a1b5 100644
--- a/src/common/notify.c
+++ b/src/common/notify.c
@@ -293,26 +293,20 @@ notify_set_offline_list (server * serv, char *users, int quiet,
 	struct notify_per_server *servnot;
 	char nick[NICKLEN];
 	char *token, *chr;
-	int pos;
 
 	token = strtok (users, ",");
 	while (token != NULL)
 	{
 		chr = strchr (token, '!');
-		if (!chr)
-			goto end;
+		if (chr != NULL)
+			*chr = '\0';
 
-		pos = chr - token;
-		if (pos + 1 >= sizeof(nick))
-			goto end;
-
-		memset (nick, 0, sizeof(nick));
-		strncpy (nick, token, pos);
+		g_strlcpy (nick, token, sizeof(nick));
 
 		servnot = notify_find (serv, nick);
 		if (servnot)
 			notify_announce_offline (serv, servnot, nick, quiet, tags_data);
-end:
+
 		token = strtok (NULL, ",");
 	}
 }
@@ -324,26 +318,20 @@ notify_set_online_list (server * serv, char *users,
 	struct notify_per_server *servnot;
 	char nick[NICKLEN];
 	char *token, *chr;
-	int pos;
 
 	token = strtok (users, ",");
 	while (token != NULL)
 	{
 		chr = strchr (token, '!');
-		if (!chr)
-			goto end;
+		if (chr != NULL)
+			*chr = '\0';
 
-		pos = chr - token;
-		if (pos + 1 >= sizeof(nick))
-			goto end;
-
-		memset (nick, 0, sizeof(nick));
-		strncpy (nick, token, pos);
+		g_strlcpy (nick, token, sizeof(nick));
 
 		servnot = notify_find (serv, nick);
 		if (servnot)
 			notify_announce_online (serv, servnot, nick, tags_data);
-end:
+
 		token = strtok (NULL, ",");
 	}
 }