From: Brian Aker Date: Tue, 20 Nov 2007 01:42:26 +0000 (-0800) Subject: Fix for poorly terminated hostname. X-Git-Tag: 0.10~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=49ab2114abe5e8c3abde24b8ec3f2bc74bfded83;p=awesomized%2Flibmemcached Fix for poorly terminated hostname. Fix in enum return type (misspelling). --- diff --git a/ChangeLog b/ChangeLog index b880e29d..022ee4ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ runtime. * Added the utility memerror to create human readable error strings from memcached errors (aka convert ints to strings) + * Fixed type in MEMCACHED_HOST_LOOKUP_FAILURE + * Fixed bug where hostname might not be null terminated 0.9 Thu Nov 15 07:44:00 PST 2007 * fix for when no servers are definied. diff --git a/include/memcached.h b/include/memcached.h index 33fa053d..e64bfb5d 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -36,7 +36,7 @@ typedef struct memcached_server_st memcached_server_st; typedef enum { MEMCACHED_SUCCESS, MEMCACHED_FAILURE, - MEMCACHED_HOST_LOCKUP_FAILURE, + MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_CONNECTION_BIND_FAILURE, MEMCACHED_WRITE_FAILURE, diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index fffd2b88..f323e79f 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -13,7 +13,9 @@ static memcached_return set_hostinfo(memcached_server_st *server) if ((h= gethostbyname(server->hostname)) == NULL) { - return MEMCACHED_HOST_LOCKUP_FAILURE; + WATCHPOINT_STRING(server->hostname); + WATCHPOINT_STRING(hstrerror(h_errno)); + return MEMCACHED_HOST_LOOKUP_FAILURE; } server->servAddr.sin_family= h->h_addrtype; @@ -210,6 +212,9 @@ memcached_return memcached_connect(memcached_st *ptr, unsigned int server_key) rc= unix_socket_connect(ptr, server_key); break; } + + if (rc != MEMCACHED_SUCCESS) + WATCHPOINT_ERROR(rc); } else { @@ -240,7 +245,10 @@ memcached_return memcached_connect(memcached_st *ptr, unsigned int server_key) rc= MEMCACHED_SUCCESS; if (possible_rc != MEMCACHED_SUCCESS) + { + WATCHPOINT_ERROR(possible_rc); rc= MEMCACHED_SOME_ERRORS; + } } } LIBMEMCACHED_MEMCACHED_CONNECT_END(); diff --git a/lib/memcached_hosts.c b/lib/memcached_hosts.c index d5ec5606..9e9c6673 100644 --- a/lib/memcached_hosts.c +++ b/lib/memcached_hosts.c @@ -125,6 +125,7 @@ static memcached_return server_add(memcached_st *ptr, char *hostname, return MEMCACHED_MEMORY_ALLOCATION_FAILURE; memcpy(new_hostname, hostname, strlen(hostname)); + new_hostname[strlen(hostname)]= 0; host_reset(&ptr->hosts[ptr->number_of_hosts], new_hostname, port, type); ptr->number_of_hosts++; diff --git a/lib/memcached_strerror.c b/lib/memcached_strerror.c index d2da6963..65e837e8 100644 --- a/lib/memcached_strerror.c +++ b/lib/memcached_strerror.c @@ -8,7 +8,7 @@ char *memcached_strerror(memcached_st *ptr, memcached_return rc) return "SUCCESS"; case MEMCACHED_FAILURE: return "FAILURE"; - case MEMCACHED_HOST_LOCKUP_FAILURE: + case MEMCACHED_HOST_LOOKUP_FAILURE: return "HOSTNAME LOOKUP FAILURE"; case MEMCACHED_CONNECTION_FAILURE: return "CONNECTION FAILURE";