Checking in the parser/scanner files.
[awesomized/libmemcached] / libmemcached / connect.c
index c4b263e1fe2fadcd8f917aa223b81e17146cf418..58a6cfd2756f037ff3d130e981c40fcfeb5674fc 100644 (file)
@@ -19,16 +19,12 @@ static memcached_return_t connect_poll(memcached_server_st *ptr)
   fds[0].fd = ptr->fd;
   fds[0].events = POLLOUT;
 
-  int timeout= ptr->root->connect_timeout;
-  if (ptr->root->flags.no_block == true)
-    timeout= -1;
-
   int error;
   size_t loop_max= 5;
 
   while (--loop_max) // Should only loop on cases of ERESTART or EINTR
   {
-    error= poll(fds, 1, timeout);
+    error= poll(fds, 1, ptr->root->connect_timeout);
 
     switch (error)
     {
@@ -95,7 +91,9 @@ static memcached_return_t set_hostinfo(memcached_server_st *server)
   char str_port[NI_MAXSERV];
   uint32_t counter= 5;
 
-  snprintf(str_port, NI_MAXSERV, "%u", (uint32_t)server->port);
+  int length= snprintf(str_port, NI_MAXSERV, "%u", (uint32_t)server->port);
+  if (length >= NI_MAXSERV || length < 0)
+    return MEMCACHED_FAILURE;
 
   memset(&hints, 0, sizeof(hints));
 
@@ -337,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,