X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fconnect.c;h=3afef7d32c99723cecb30fd76c864d43ad89df2e;hb=4209d822c35fea2ca1c5879e18bc6c063dba4c41;hp=7b38def933762ad29d29c52cf7f5a2952b520bbd;hpb=2230ba7b89bbaa989de311f9d7ea6d6e2cd5a9b8;p=m6w6%2Flibmemcached diff --git a/libmemcached/connect.c b/libmemcached/connect.c index 7b38def9..3afef7d3 100644 --- a/libmemcached/connect.c +++ b/libmemcached/connect.c @@ -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) { @@ -80,7 +76,6 @@ static memcached_return_t connect_poll(memcached_server_st *ptr) return MEMCACHED_ERRNO; } } - WATCHPOINT_ASSERT(0); // Programming error } // This should only be possible from ERESTART or EINTR; @@ -96,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)); @@ -537,7 +534,7 @@ memcached_return_t memcached_connect(memcached_server_write_instance_st ptr) case MEMCACHED_CONNECTION_TCP: rc= network_connect(ptr); #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT - if (ptr->fd != INVALID_SOCKET && ptr->root->sasl && ptr->root->sasl->callbacks) + if (ptr->fd != INVALID_SOCKET && ptr->root->sasl.callbacks) { rc= memcached_sasl_authenticate_connection(ptr); if (rc != MEMCACHED_SUCCESS)