pidgin/android/libpurple
Add some error checking for sscanf usage (there are more places that could use this)
* Also a trivial unused variable fix
--- a/finch/gntpounce.c Sat Mar 02 13:59:59 2013 -0500
+++ b/finch/gntpounce.c Sat Mar 02 17:20:56 2013 -0500
@@ -801,10 +801,8 @@
if (purple_pounce_action_is_enabled(pounce, "open-window"))
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account);
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee);
+ if (!purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account)) + purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); if (purple_pounce_action_is_enabled(pounce, "popup-notify"))
--- a/libpurple/example/nullclient.c Sat Mar 02 13:59:59 2013 -0500
+++ b/libpurple/example/nullclient.c Sat Mar 02 17:20:56 2013 -0500
@@ -253,7 +253,7 @@
+ const char *prpl = NULL; GMainLoop *loop = g_main_loop_new(NULL, FALSE);
@@ -289,8 +289,12 @@
fprintf(stderr, "Failed to gets protocol selection.");
- sscanf(name, "%d", &num);
- prpl = g_list_nth_data(names, num);
+ if (sscanf(name, "%d", &num) == 1) + prpl = g_list_nth_data(names, num); + fprintf(stderr, "Failed to gets protocol."); res = fgets(name, sizeof(name), stdin);
--- 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 @@
} else if (!strncmp(cur, "PING ", 5)) {
if (notice) { /* reply */
- /* TODO: Should this read in the timestamp as a double? */
- sscanf(cur, "PING %lu", ×tamp);
gc = purple_account_get_connection(irc->account);
- buf = g_strdup_printf(_("Reply time from %s: %lu seconds"), from, time(NULL) - timestamp);
- purple_notify_info(gc, _("PONG"), _("CTCP PING reply"), buf);
+ /* TODO: Should this read in the timestamp as a double? */ + if (sscanf(cur, "PING %lu", ×tamp) == 1) { + buf = g_strdup_printf(_("Reply time from %s: %lu seconds"), from, time(NULL) - timestamp); + purple_notify_info(gc, _("PONG"), _("CTCP PING reply"), buf); + purple_debug(PURPLE_DEBUG_ERROR, "irc", "Unable to parse PING timestamp"); buf = irc_format(irc, "vt:", "NOTICE", from, msg);
--- a/libpurple/protocols/jabber/oob.c Sat Mar 02 13:59:59 2013 -0500
+++ b/libpurple/protocols/jabber/oob.c Sat Mar 02 17:20:56 2013 -0500
@@ -138,8 +138,13 @@
lenstr = strstr(jox->headers->str, "Content-Length: ");
- sscanf(lenstr, "Content-Length: %d", &size);
- purple_xfer_set_size(xfer, size);
+ if (sscanf(lenstr, "Content-Length: %d", &size) == 1) + purple_xfer_set_size(xfer, size); + purple_debug_error("jabber", "Unable to parse Content-Length!\n"); + purple_xfer_cancel_local(xfer); purple_xfer_set_read_fnc(xfer, NULL);
--- a/libpurple/protocols/msn/soap.c Sat Mar 02 13:59:59 2013 -0500
+++ b/libpurple/protocols/msn/soap.c Sat Mar 02 17:20:56 2013 -0500
@@ -426,7 +426,8 @@
} else if (strcmp(key, "Content-Length") == 0) {
- sscanf(value, "%" G_GSIZE_FORMAT, &(conn->body_len));
+ if (sscanf(value, "%" G_GSIZE_FORMAT, &(conn->body_len)) != 1) + purple_debug_error("soap", "Unable to parse Content-Length\n"); } else if (strcmp(key, "Connection") == 0) {
if (strcmp(value, "close") == 0) {
conn->close_when_done = TRUE;
--- a/libpurple/util.c Sat Mar 02 13:59:59 2013 -0500
+++ b/libpurple/util.c Sat Mar 02 17:20:56 2013 -0500
@@ -3535,7 +3535,8 @@
- sscanf(port_str, "%d", &port);
+ if (sscanf(port_str, "%d", &port) != 1) + purple_debug_error("util", "Error parsing URL port from %s\n", url); if (ret_host != NULL) *ret_host = g_strdup(host);
if (ret_port != NULL) *ret_port = port;