Cleanup from memaslap
[awesomized/libmemcached] / clients / utilities.c
index 52f46b40562fc55b1bcc5b4b79ea1944de643cd8..92987471558d60f130020faf800f42740ccd64fd 100644 (file)
@@ -71,9 +71,10 @@ static const char *lookup_help(memcached_options option)
 
 void help_command(const char *command_name, const char *description,
                   const struct option *long_options,
-                  memcached_programs_help_st *options __attribute__((unused)))
+                  memcached_programs_help_st *options)
 {
   unsigned int x;
+  (void)options;
 
   printf("%s v%u.%u\n\n", command_name, 1U, 0U);
   printf("\t%s\n\n", description);
@@ -148,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;
@@ -160,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;
 }