From: Brian Aker Date: Sun, 7 Oct 2012 02:07:09 +0000 (-0400) Subject: Fix for lp:1062704 X-Git-Tag: 1.0.12~5 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c6e2eddc3a033d9e382846f1771a9cb0bcc0cba7;p=m6w6%2Flibmemcached Fix for lp:1062704 --- diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc index 61c1b059..62b362ad 100644 --- a/libmemcached/hosts.cc +++ b/libmemcached/hosts.cc @@ -507,9 +507,9 @@ memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *pt } memcached_string_t _filename= { memcached_string_make_from_cstr(filename) }; - if (memcached_is_valid_servername(_filename) == false) + if (memcached_is_valid_filename(_filename) == false) { - memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid filename for socket provided")); + return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid filename for socket provided")); } return server_add(ptr, _filename, 0, weight, MEMCACHED_CONNECTION_UNIX_SOCKET); diff --git a/libmemcached/server.hpp b/libmemcached/server.hpp index 2719294f..351b34be 100644 --- a/libmemcached/server.hpp +++ b/libmemcached/server.hpp @@ -60,7 +60,12 @@ void __server_free(memcached_server_st *); static inline bool memcached_is_valid_servername(const memcached_string_t& arg) { - return arg.size < NI_MAXHOST; + return (arg.c_str != NULL or arg.size == 0) and arg.size < NI_MAXHOST; +} + +static inline bool memcached_is_valid_filename(const memcached_string_t& arg) +{ + return arg.c_str != NULL and arg.size > 0 and arg.size < NI_MAXHOST; } void memcached_instance_free(org::libmemcached::Instance *);