File memcached-1.2.8_proper_vlen_fix.patch of Package memcached

Index: memcached.c
===================================================================
--- memcached.c.orig	2009-08-06 15:08:34.260286896 +0200
+++ memcached.c	2009-08-06 15:08:34.280288516 +0200
@@ -1374,7 +1374,7 @@ static void process_update_command(conn
 
     flags = strtoul(tokens[2].value, NULL, 10);
     exptime = strtol(tokens[3].value, NULL, 10);
-    vlen = strtol(tokens[4].value, NULL, 10);
+    vlen = strtol(tokens[4].value, NULL, 10) + 2;
 
     // does cas value exist?
     if(handle_cas)
@@ -1383,7 +1383,7 @@ static void process_update_command(conn
     }
 
     if(errno == ERANGE || ((flags == 0 || exptime == 0) && errno == EINVAL)
-       || vlen < 0) {
+       || vlen < 0 || vlen - 2 < 0) {
         out_string(c, "CLIENT_ERROR bad command line format");
         return;
     }
@@ -1405,16 +1405,16 @@ static void process_update_command(conn
         }
     }
 
-    it = item_alloc(key, nkey, flags, realtime(exptime), vlen+2);
+    it = item_alloc(key, nkey, flags, realtime(exptime), vlen);
 
     if (it == 0) {
-        if (! item_size_ok(nkey, flags, vlen + 2))
+        if (! item_size_ok(nkey, flags, vlen))
             out_string(c, "SERVER_ERROR object too large for cache");
         else
             out_string(c, "SERVER_ERROR out of memory storing object");
         /* swallow the data line */
         c->write_and_go = conn_swallow;
-        c->sbytes = vlen + 2;
+        c->sbytes = vlen;
 
         /* Avoid stale data persisting in cache because we failed alloc.
          * Unacceptable for SET. Anywhere else too? */
openSUSE Build Service is sponsored by