libpurple/protocols/irc/parse.c

branch
release-2.x.y
changeset 33809
d5e9c888ccd7
parent 33544
3780e4cb9738
child 33811
5ab172aeeff2
child 35182
639ec03ba1ba
child 35245
a167504359e5
--- a/libpurple/protocols/irc/parse.c	Sat Mar 02 13:59:59 2013 -0500
+++ b/libpurple/protocols/irc/parse.c	Sat Mar 02 17:20:56 2013 -0500
@@ -559,14 +559,16 @@
 		return buf;
 	} else if (!strncmp(cur, "PING ", 5)) {
 		if (notice) { /* reply */
-			/* TODO: Should this read in the timestamp as a double? */
-			sscanf(cur, "PING %lu", &timestamp);
 			gc = purple_account_get_connection(irc->account);
 			if (!gc)
 				return NULL;
-			buf = g_strdup_printf(_("Reply time from %s: %lu seconds"), from, time(NULL) - timestamp);
-			purple_notify_info(gc, _("PONG"), _("CTCP PING reply"), buf);
-			g_free(buf);
+			/* TODO: Should this read in the timestamp as a double? */
+			if (sscanf(cur, "PING %lu", &timestamp) == 1) {
+				buf = g_strdup_printf(_("Reply time from %s: %lu seconds"), from, time(NULL) - timestamp);
+				purple_notify_info(gc, _("PONG"), _("CTCP PING reply"), buf);
+				g_free(buf);
+			} else
+				purple_debug(PURPLE_DEBUG_ERROR, "irc", "Unable to parse PING timestamp");
 			return NULL;
 		} else {
 			buf = irc_format(irc, "vt:", "NOTICE", from, msg);

mercurial