Fixed unittests and vc-changelog.
[m6w6/libmemcached] / libmemcached / callback.c
index 252b4334e66166b2985def805da973457a5b9ed3..aba1a383670afd4cf0d297b9f54de423a259dc6f 100644 (file)
@@ -11,8 +11,6 @@
 
 #include "common.h"
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/tcp.h>
 
 /*
   These functions provide data and function callback support
@@ -38,7 +36,7 @@ memcached_return_t memcached_callback_set(memcached_st *ptr,
         }
 
         if ((key_length > MEMCACHED_PREFIX_KEY_MAX_SIZE -1)
-            || (strcpy(ptr->prefix_key, key) == NULL))
+            || (strncpy(ptr->prefix_key, key, MEMCACHED_PREFIX_KEY_MAX_SIZE) == NULL))
         {
           ptr->prefix_key_length= 0;
           return MEMCACHED_BAD_KEY_PROVIDED;
@@ -50,7 +48,7 @@ memcached_return_t memcached_callback_set(memcached_st *ptr,
       }
       else
       {
-        memset(ptr->prefix_key, 0, MEMCACHED_PREFIX_KEY_MAX_SIZE);
+        ptr->prefix_key[0]= 0;
         ptr->prefix_key_length= 0;
       }
 
@@ -126,15 +124,15 @@ void *memcached_callback_get(memcached_st *ptr,
   {
   case MEMCACHED_CALLBACK_PREFIX_KEY:
     {
-      if (ptr->prefix_key[0] == 0)
+      if (ptr->prefix_key_length)
       {
-        *error= MEMCACHED_FAILURE;
-        return NULL;
+        *error= MEMCACHED_SUCCESS;
+        return (void *)ptr->prefix_key;
       }
       else
       {
-        *error= MEMCACHED_SUCCESS;
-        return (void *)ptr->prefix_key;
+        *error= MEMCACHED_FAILURE;
+        return NULL;
       }
     }
   case MEMCACHED_CALLBACK_USER_DATA: