changeset 17954:016f9b2d6ee0

Increase read buffer size and be more careful about overruns.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Thu, 19 Jul 2007 04:09:33 +0000
parents bde17299004b
children 9e8943111022
files libpurple/protocols/myspace/myspace.c libpurple/protocols/myspace/myspace.h
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Wed Jul 18 06:09:32 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Thu Jul 19 04:09:33 2007 +0000
@@ -1098,6 +1098,12 @@
    
     bm = msim_msg_get_integer(msg, "bm");
 
+    if (msim_msg_get(msg, "cv"))
+    {
+        purple_debug_info("msim_incoming_bm", "cv=%s",
+                msim_msg_get_string(msg, "cv"));
+    }
+
     switch (bm)
     {
         case MSIM_BM_STATUS:
@@ -2137,7 +2143,7 @@
         g_return_val_if_fail(uid, FALSE);
     }
 
-	purple_debug_info("msim", "associating uid %d with username %s\n", uid, username);
+	purple_debug_info("msim", "associating uid %s with username %s\n", uid, username);
 
 	buddy = purple_find_buddy(session->account, username);
 	if (buddy)
@@ -2716,10 +2722,11 @@
      * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE.
      * Should be large enough to hold the largest protocol message.
      */
-    if (session->rxoff == MSIM_READ_BUF_SIZE)
+    if (session->rxoff >= MSIM_READ_BUF_SIZE)
     {
-        purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n",
-                MSIM_READ_BUF_SIZE);
+        purple_debug_error("msim", 
+                "msim_input_cb: %d-byte read buffer full! rxoff=%d\n",
+                MSIM_READ_BUF_SIZE, session->rxoff);
         purple_connection_error(gc, _("Read buffer full"));
         return;
     }
@@ -2752,6 +2759,13 @@
         return;
     }
 
+    if (n + session->rxoff >= MSIM_READ_BUF_SIZE)
+    {
+        purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n",
+                n, n + session->rxoff, MSIM_READ_BUF_SIZE);
+        purple_connection_error(gc, _("Read buffer full"));
+    }
+
     /* Null terminate */
     purple_debug_info("msim", "msim_input_cb: going to null terminate "
             "at n=%d\n", n);
--- a/libpurple/protocols/myspace/myspace.h	Wed Jul 18 06:09:32 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.h	Thu Jul 19 04:09:33 2007 +0000
@@ -95,7 +95,7 @@
 /* Constants */
 #define HASH_SIZE           0x14        /**< Size of SHA-1 hash for login */
 #define NONCE_SIZE          0x20        /**< Half of decoded 'nc' field */
-#define MSIM_READ_BUF_SIZE  (5 * 1024)  /**< Receive buffer size */
+#define MSIM_READ_BUF_SIZE  (15 * 1024) /**< Receive buffer size */
 #define MSIM_FINAL_STRING   "\\final\\" /**< Message end marker */
 
 /* Messages */