Merge fixes from build.
authorBrian Aker <brian@tangent.org>
Fri, 25 Mar 2011 00:48:22 +0000 (17:48 -0700)
committerBrian Aker <brian@tangent.org>
Fri, 25 Mar 2011 00:48:22 +0000 (17:48 -0700)
18 files changed:
clients/execute.c
clients/utilities.c
example/memcached_light.c
libhashkit/digest.c
libhashkit/hsieh.c
libhashkit/ketama.c
libmemcached/behavior.c
libmemcached/connect.c
libmemcached/hash.c
libmemcached/hosts.c
libmemcached/io.c
libmemcached/protocol/ascii_handler.c
libmemcached/quit.c
libmemcached/sasl.c
libmemcached/server_list.c
libmemcached/stats.c
libmemcached/version.c
tests/mem_functions.c

index dbc102c68af0f062501dfead9e98e9c6be6fb49b..0beaae4bd85229208b704568dac68f854ca435f2 100644 (file)
@@ -116,7 +116,7 @@ unsigned int execute_mget(memcached_st *memc,
       fprintf(stderr, "Failed to execute mget: %s\n",
               memcached_strerror(memc, rc));
       memcached_quit(memc);
-      return EXIT_SUCCESS;
+      return 0;
     }
   }
   else
@@ -124,7 +124,7 @@ unsigned int execute_mget(memcached_st *memc,
     fprintf(stderr, "Failed to execute mget: %s\n",
             memcached_strerror(memc, rc));
     memcached_quit(memc);
-    return EXIT_SUCCESS;
+    return 0;
   }
 
   return retrieved;
index f223ae6fd0d4ca6ede0fb67fb6f6e8cbc6248e84..92987471558d60f130020faf800f42740ccd64fd 100644 (file)
@@ -149,7 +149,7 @@ static int get_password(sasl_conn_t *conn, void *context, int id,
                         sasl_secret_t **psecret)
 {
   (void)context;
-  static sasl_secret_t* x;
+  static sasl_secret_t* ptr;
 
   if (!conn || ! psecret || id != SASL_CB_PASS)
     return SASL_BADPARAM;
@@ -161,14 +161,15 @@ static int get_password(sasl_conn_t *conn, void *context, int id,
   }
 
   size_t len= strlen(passwd);
-  x = realloc(x, sizeof(sasl_secret_t) + len);
-  if (!x)
+  ptr= malloc(sizeof(sasl_secret_t) + len +1);
+  if (! ptr)
     return SASL_NOMEM;
 
-  x->len = len;
-  strcpy((void *)x->data, passwd);
+  ptr->len= len;
+  memcpy(ptr->data, passwd, len);
+  ptr->data[len]= 0;
 
-  *psecret = x;
+  *psecret= ptr;
   return SASL_OK;
 }
 
index 8465ff287d5ace3291ccc3e44b36db364ab6242d..6a87ff1917ace469f334c7fc62be6139e3a3bf5d 100644 (file)
@@ -180,7 +180,7 @@ static int server_socket(const char *port)
     else
       perror("getaddrinfo()");
 
-    return EXIT_FAILURE;
+    return 0;
   }
 
   struct linger ling= {0, 0};
index f418dc0b644c40309e444cc58a8452b665583026..4ff6de29f08f11e2d5d092afbe512b00dd5f5dba 100644 (file)
@@ -35,13 +35,13 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo
 #ifdef HAVE_HSIEH_HASH
     return libhashkit_hsieh(key, key_length);
 #else
-    return EXIT_FAILURE;
+    return 1;
 #endif
   case HASHKIT_HASH_MURMUR:
 #ifdef HAVE_MURMUR_HASH
     return libhashkit_murmur(key, key_length);
 #else
-    return EXIT_FAILURE;
+    return 1;
 #endif
   case HASHKIT_HASH_JENKINS:
     return libhashkit_jenkins(key, key_length);
@@ -56,5 +56,5 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo
     break;
   }
 
-  return EXIT_FAILURE;
+  return 1;
 }
index cb5af8aec74524540fd97afb2b1bac0ffd797c07..ba46ed2cdf71c3b59e1f43691703885722c7c4f5 100644 (file)
@@ -23,7 +23,7 @@ uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attri
   int rem;
 
   if (key_length <= 0 || key == NULL)
-    return EXIT_SUCCESS;
+    return 0;
 
   rem = key_length & 3;
   key_length >>= 2;
index 560de30031ccc329a5afcc4a3b238e3da4fb3a96..a510e57ab1ea802026d185cfcde3693c1fec7633 100644 (file)
@@ -27,9 +27,9 @@ static int continuum_points_cmp(const void *t1, const void *t2)
   hashkit_continuum_point_st *ct2= (hashkit_continuum_point_st *)t2;
 
   if (ct1->value == ct2->value)
-    return EXIT_SUCCESS;
+    return 0;
   else if (ct1->value > ct2->value)
-    return EXIT_FAILURE;
+    return 1;
   else
     return -1;
 }
@@ -71,7 +71,7 @@ int update_continuum(hashkit_st *hashkit)
     live_servers= (uint32_t)hashkit->list_size;
 
   if (live_servers == 0)
-    return EXIT_SUCCESS;
+    return 0;
 
   if (hashkit->weight_fn == NULL)
   {
@@ -159,6 +159,6 @@ int update_continuum(hashkit_st *hashkit)
   qsort(hashkit->continuum, hashkit->continuum_points_count, sizeof(hashkit_continuum_point_st),
         continuum_points_cmp);
 
-  return EXIT_SUCCESS;
+  return 0;
 }
 #endif
index f88f0a771c1f556d926a20322cfb776da7f46789..2b6ccdf9112fda235bb2dc163497b9b49fd712f4 100644 (file)
@@ -314,18 +314,18 @@ uint64_t memcached_behavior_get(memcached_st *ptr,
         /* We just try the first host, and if it is down we return zero */
         if ((memcached_connect(instance)) != MEMCACHED_SUCCESS)
         {
-          return EXIT_SUCCESS;
+          return 0;
         }
 
         if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS)
         {
-          return EXIT_SUCCESS;
+          return 0;
         }
 
         if (getsockopt(instance->fd, SOL_SOCKET, SO_SNDBUF, &sock_size, &sock_length) < 0)
         {
           ptr->cached_errno= errno;
-          return EXIT_SUCCESS; /* Zero means error */
+          return 0; /* Zero means error */
         }
       }
 
@@ -350,18 +350,18 @@ uint64_t memcached_behavior_get(memcached_st *ptr,
         /* We just try the first host, and if it is down we return zero */
         if ((memcached_connect(instance)) != MEMCACHED_SUCCESS)
         {
-          return EXIT_SUCCESS;
+          return 0;
         }
 
         if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS)
         {
-          return EXIT_SUCCESS;
+          return 0;
         }
 
         if (getsockopt(instance->fd, SOL_SOCKET, SO_RCVBUF, &sock_size, &sock_length) < 0)
         {
           ptr->cached_errno= errno;
-          return EXIT_SUCCESS; /* Zero means error */
+          return 0; /* Zero means error */
         }
 
       }
@@ -385,7 +385,7 @@ uint64_t memcached_behavior_get(memcached_st *ptr,
   case MEMCACHED_BEHAVIOR_MAX:
   default:
     WATCHPOINT_ASSERT(0); /* Programming mistake if it gets this far */
-    return EXIT_SUCCESS;
+    return 0;
   }
 
   /* NOTREACHED */
index 3afef7d32c99723cecb30fd76c864d43ad89df2e..58a6cfd2756f037ff3d130e981c40fcfeb5674fc 100644 (file)
@@ -335,7 +335,7 @@ static memcached_return_t unix_socket_connect(memcached_server_st *ptr)
 
   memset(&servAddr, 0, sizeof (struct sockaddr_un));
   servAddr.sun_family= AF_UNIX;
-  strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */
+  strncpy(servAddr.sun_path, ptr->hostname, sizeof(servAddr.sun_path)); /* Copy filename */
 
 test_connect:
   if (connect(ptr->fd,
index abad4f5bf3bce3951ee0f019560a733addca00fa..dda303952a5c86c2e6cc76de52c5a440474795eb 100644 (file)
@@ -70,7 +70,7 @@ static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const cha
   WATCHPOINT_ASSERT(memcached_server_count(ptr));
 
   if (memcached_server_count(ptr) == 1)
-    return EXIT_SUCCESS;
+    return 0;
 
   if (ptr->flags.hash_with_prefix_key)
   {
@@ -78,7 +78,7 @@ static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const cha
     char temp[temp_length];
 
     if (temp_length > MEMCACHED_MAX_KEY -1)
-      return EXIT_SUCCESS;
+      return 0;
 
     strncpy(temp, ptr->prefix_key, ptr->prefix_key_length);
     strncpy(temp + ptr->prefix_key_length, key, key_length);
index 7034d3ec366dd5288ad9b8783b5ee2ca24a356a3..9723f8b628ad8c49b42d3d1d6c4388ce63e8a22d 100644 (file)
@@ -92,9 +92,9 @@ static int continuum_item_cmp(const void *t1, const void *t2)
   /* Why 153? Hmmm... */
   WATCHPOINT_ASSERT(ct1->value != 153);
   if (ct1->value == ct2->value)
-    return EXIT_SUCCESS;
+    return 0;
   else if (ct1->value > ct2->value)
-    return EXIT_FAILURE;
+    return 1;
   else
     return -1;
 }
index 2515dc1ea7c72b5f5e2a42404d3aa11f23233c4f..dedcdaf9e9deff939b1d599255263dae8baa4d30 100644 (file)
@@ -314,7 +314,7 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
             and protocol enforcement happens at memcached_response()
             looking for '\n'. We do not care for UDB which requests 8 bytes
             at once. Generally, this means that connection went away. Since
-            for blocking I/O we do not return EXIT_SUCCESS and for non-blocking case
+            for blocking I/O we do not return 0 and for non-blocking case
             it will return EGAIN if data is not immediatly available.
           */
           WATCHPOINT_STRING("We had a zero length recv()");
@@ -600,7 +600,7 @@ static ssize_t io_flush(memcached_server_write_instance_st ptr,
 
   if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP
                                         && ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH))
-    return EXIT_SUCCESS;
+    return 0;
 
   /* Looking for memory overflows */
 #if defined(DEBUG)
index 802b0859653351647b2ab2284ea21b1a1b3296c4..465b73969766432963007dfabe7ea9e4e42b2c43 100644 (file)
@@ -34,7 +34,7 @@ static uint16_t parse_ascii_key(char **start)
 
   if (len == 0 || len > 240 || (*c != '\0' && *c != '\r' && iscntrl(*c)))
   {
-    return EXIT_SUCCESS;
+    return 0;
   }
 
   return len;
@@ -558,7 +558,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
   {
     /* Keep on reading */
     recover_tokenize_command(start, *end);
-    return EXIT_FAILURE;
+    return 1;
   }
 
   void *data= (*end) + 1;
@@ -658,7 +658,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
 
   *end += nbytes + 2;
 
-  return EXIT_SUCCESS;
+  return 0;
 }
 
 static int process_cas_command(memcached_protocol_client_st *client,
index 251f578cdd9e2d801bdb78929bd5bc309c7547d1..a82470000ff6496477e0cea7fcbc5f58dd62c57b 100644 (file)
@@ -11,7 +11,7 @@
 
 void memcached_quit_server(memcached_server_st *ptr, bool io_death)
 {
-  if (ptr->fd != -1)
+  if (ptr->fd != INVALID_SOCKET)
   {
     if (io_death == false && ptr->type != MEMCACHED_CONNECTION_UDP && ptr->options.is_shutting_down == false)
     {
@@ -30,7 +30,7 @@ void memcached_quit_server(memcached_server_st *ptr, bool io_death)
       }
       else
       {
-        rc= memcached_do(ptr, "quit\r\n", strlen("quit\r\n"), true);
+        rc= memcached_do(ptr, "quit\r\n", sizeof("quit\r\n") -1, true);
       }
 
       WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
@@ -64,7 +64,7 @@ void memcached_quit_server(memcached_server_st *ptr, bool io_death)
     memcached_io_close(ptr);
   }
 
-  ptr->fd= -1;
+  ptr->fd= INVALID_SOCKET;
   ptr->io_bytes_sent= 0;
   ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0);
   ptr->read_buffer_length= 0;
@@ -85,14 +85,9 @@ void memcached_quit_server(memcached_server_st *ptr, bool io_death)
 
 void memcached_quit(memcached_st *ptr)
 {
-  uint32_t x;
-
-  if (memcached_server_count(ptr) == 0)
-    return;
-
   if (memcached_server_count(ptr))
   {
-    for (x= 0; x < memcached_server_count(ptr); x++)
+    for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
     {
       memcached_server_write_instance_st instance=
         memcached_server_instance_fetch(ptr, x);
index 0dedb52db45fb3cc8e593ad602d927ccd44d18b3..669207950d56342680d7078ba4503652223383e4 100644 (file)
@@ -225,8 +225,8 @@ memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr,
 
   sasl_callback_t *cb= libmemcached_calloc(ptr, 4, sizeof(sasl_callback_t));
   char *name= libmemcached_malloc(ptr, strlen(username) + 1);
-  sasl_secret_t *secret= libmemcached_malloc(ptr, strlen(password) + 1 + sizeof(*secret))
-;
+  size_t password_length= strlen(password);
+  sasl_secret_t *secret= libmemcached_malloc(ptr, password_length +1 + sizeof(*secret));
   if (cb == NULL || name == NULL || secret == NULL)
   {
     libmemcached_free(ptr, cb);
@@ -236,11 +236,12 @@ memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr,
   }
 
   secret->len= strlen(password);
-  strcpy((void*)secret->data, password);
+  memcpy(secret->data, password, password_length);
+  secret->data[password_length]= 0;
 
   cb[0].id= SASL_CB_USER;
   cb[0].proc= get_username;
-  cb[0].context= strcpy(name, username);
+  cb[0].context= strncpy(name, username, sizeof(cb[0].context));
   cb[1].id= SASL_CB_AUTHNAME;
   cb[1].proc= get_username;
   cb[1].context= name;
@@ -346,7 +347,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const  memcached_st
         libmemcached_free(clone, cb);
         return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
       }
-      strcpy(cb[x].context, source->sasl.callbacks[x].context);
+      strncpy(cb[x].context, source->sasl.callbacks[x].context, sizeof(cb[x].context));
     }
     else
     {
index 64b8b0c4c83ed101c0cdac2198f8863dccb882a1..ca37f7f9a4b3f159e5f8747d50be33c4918a3698 100644 (file)
@@ -24,7 +24,9 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr,
   if (hostname == NULL || error == NULL)
     return NULL;
 
-  if (! port)
+  if (hostname[0] == '/')
+    port = 0;
+  else if (! port)
     port= MEMCACHED_DEFAULT_PORT;
 
   /* Increment count for hosts */
@@ -43,7 +45,7 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr,
   }
 
   /* @todo Check return type */
-  memcached_server_create_with(NULL, &new_host_list[count-1], hostname, port, weight, MEMCACHED_CONNECTION_TCP);
+  memcached_server_create_with(NULL, &new_host_list[count-1], hostname, port, weight, port ? MEMCACHED_CONNECTION_TCP : MEMCACHED_CONNECTION_UNIX_SOCKET);
 
   // Handset allocated since 
   new_host_list->options.is_allocated= true;
index ebbc63ab9b8ba05be502160ccfb82886e3f5052b..5a37dfd9130fdd528e0481e6c404b9c730b90e04 100644 (file)
@@ -178,49 +178,49 @@ char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_
 
   *error= MEMCACHED_SUCCESS;
 
-  if (!memcmp("pid", key, strlen("pid")))
+  if (!memcmp("pid", key, sizeof("pid") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pid);
-  else if (!memcmp("uptime", key, strlen("uptime")))
+  else if (!memcmp("uptime", key, sizeof("uptime") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->uptime);
-  else if (!memcmp("time", key, strlen("time")))
+  else if (!memcmp("time", key, sizeof("time") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->time);
-  else if (!memcmp("version", key, strlen("version")))
+  else if (!memcmp("version", key, sizeof("version") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%s", memc_stat->version);
-  else if (!memcmp("pointer_size", key, strlen("pointer_size")))
+  else if (!memcmp("pointer_size", key, sizeof("pointer_size") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->pointer_size);
-  else if (!memcmp("rusage_user", key, strlen("rusage_user")))
+  else if (!memcmp("rusage_user", key, sizeof("rusage_user") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_user_seconds, memc_stat->rusage_user_microseconds);
-  else if (!memcmp("rusage_system", key, strlen("rusage_system")))
+  else if (!memcmp("rusage_system", key, sizeof("rusage_system") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u.%u", memc_stat->rusage_system_seconds, memc_stat->rusage_system_microseconds);
-  else if (!memcmp("curr_items", key, strlen("curr_items")))
+  else if (!memcmp("curr_items", key, sizeof("curr_items") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_items);
-  else if (!memcmp("total_items", key, strlen("total_items")))
+  else if (!memcmp("total_items", key, sizeof("total_items") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_items);
-  else if (!memcmp("curr_connections", key, strlen("curr_connections")))
+  else if (!memcmp("curr_connections", key, sizeof("curr_connections") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->curr_connections);
-  else if (!memcmp("total_connections", key, strlen("total_connections")))
+  else if (!memcmp("total_connections", key, sizeof("total_connections") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->total_connections);
-  else if (!memcmp("connection_structures", key, strlen("connection_structures")))
+  else if (!memcmp("connection_structures", key, sizeof("connection_structures") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->connection_structures);
-  else if (!memcmp("cmd_get", key, strlen("cmd_get")))
+  else if (!memcmp("cmd_get", key, sizeof("cmd_get") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_get);
-  else if (!memcmp("cmd_set", key, strlen("cmd_set")))
+  else if (!memcmp("cmd_set", key, sizeof("cmd_set") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_set);
-  else if (!memcmp("get_hits", key, strlen("get_hits")))
+  else if (!memcmp("get_hits", key, sizeof("get_hits") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_hits);
-  else if (!memcmp("get_misses", key, strlen("get_misses")))
+  else if (!memcmp("get_misses", key, sizeof("get_misses") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_misses);
-  else if (!memcmp("evictions", key, strlen("evictions")))
+  else if (!memcmp("evictions", key, sizeof("evictions") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->evictions);
-  else if (!memcmp("bytes_read", key, strlen("bytes_read")))
+  else if (!memcmp("bytes_read", key, sizeof("bytes_read") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_read);
-  else if (!memcmp("bytes_written", key, strlen("bytes_written")))
+  else if (!memcmp("bytes_written", key, sizeof("bytes_written") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_written);
-  else if (!memcmp("bytes", key, strlen("bytes")))
+  else if (!memcmp("bytes", key, sizeof("bytes") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes);
-  else if (!memcmp("limit_maxbytes", key, strlen("limit_maxbytes")))
+  else if (!memcmp("limit_maxbytes", key, sizeof("limit_maxbytes") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->limit_maxbytes);
-  else if (!memcmp("threads", key, strlen("threads")))
+  else if (! memcmp("threads", key, sizeof("threads") -1))
     length= snprintf(buffer, SMALL_STRING_LEN,"%u", memc_stat->threads);
   else
   {
index cb8fa0e057f26a7edf4991d394da854ccffff2ec..82de87d362240666b2134ee50b802c56b7e99952 100644 (file)
@@ -31,7 +31,7 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr)
   char *response_ptr;
   const char *command= "version\r\n";
 
-  send_length= strlen(command);
+  send_length= sizeof("version\r\n") -1;
 
   rc= MEMCACHED_SUCCESS;
   for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
index 74ab33a0fc692a183eb586b1475918f7c35ce533..c46ef51a1d449c3989eb7150f2658dc78915ba41 100644 (file)
@@ -784,8 +784,8 @@ static memcached_return_t  server_function(const memcached_st *ptr,
 
 static test_return_t memcached_server_cursor_test(memcached_st *memc)
 {
-  char context[8];
-  strcpy(context, "foo bad");
+  char context[10];
+  strncpy(context, "foo bad", sizeof(context));
   memcached_server_fn callbacks[1];
 
   callbacks[0]= server_function;
@@ -4001,13 +4001,13 @@ static test_return_t set_prefix(memcached_st *memc)
 
     /* Test a long key for failure */
     /* TODO, extend test to determine based on setting, what result should be */
-    strcpy(long_key, "Thisismorethentheallottednumberofcharacters");
+    strncpy(long_key, "Thisismorethentheallottednumberofcharacters", sizeof(long_key));
     rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
     //test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
     test_true(rc == MEMCACHED_SUCCESS);
 
     /* Now test a key with spaces (which will fail from long key, since bad key is not set) */
-    strcpy(long_key, "This is more then the allotted number of characters");
+    strncpy(long_key, "This is more then the allotted number of characters", sizeof(long_key));
     rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
     test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
 
@@ -4015,7 +4015,7 @@ static test_return_t set_prefix(memcached_st *memc)
     rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1);
     test_true(rc == MEMCACHED_SUCCESS);
 
-    strcpy(long_key, "dog cat");
+    strncpy(long_key, "dog cat", sizeof(long_key));
     rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
     test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
   }
@@ -5967,9 +5967,11 @@ static test_return_t wrong_failure_counter_two_test(memcached_st *memc)
   /* put failure limit to 1 */
   rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 1);
   assert(rc == MEMCACHED_SUCCESS);
+
   /* Put a retry timeout to effectively activate failure_limit effect */
   rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1);
   assert(rc == MEMCACHED_SUCCESS);
+
   /* change behavior that triggers memcached_quit()*/
   rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
   assert(rc == MEMCACHED_SUCCESS);