X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fstats.c;h=93012a8daa92725fcc8291af7b2df8f59575949e;hb=49fc1e5ea4ea006f4a2ac71428833760f6fac030;hp=0c52d97a6b4fbe8c9f1b6367dcca796b8b7c2a16;hpb=c63b3f26c9e8d0214d3e1c70fb761f7700d61d2d;p=m6w6%2Flibmemcached diff --git a/libmemcached/stats.c b/libmemcached/stats.c index 0c52d97a..93012a8d 100644 --- a/libmemcached/stats.c +++ b/libmemcached/stats.c @@ -162,7 +162,8 @@ static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char strcmp("reclaimed", key) == 0)) { WATCHPOINT_STRING(key); - return MEMCACHED_UNKNOWN_STAT_KEY; + /* return MEMCACHED_UNKNOWN_STAT_KEY; */ + return MEMCACHED_SUCCESS; } return MEMCACHED_SUCCESS; @@ -227,6 +228,12 @@ char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_ return NULL; } + if (length >= SMALL_STRING_LEN || length < 0) + { + *error= MEMCACHED_FAILURE; + return NULL; + } + ret= libmemcached_malloc(ptr, (size_t) (length + 1)); memcpy(ret, buffer, (size_t) length); ret[length]= '\0'; @@ -329,7 +336,7 @@ static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, { memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - size_t send_length; + int send_length; if (args) send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, @@ -338,10 +345,10 @@ static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "stats\r\n"); - if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) + if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) return MEMCACHED_WRITE_FAILURE; - rc= memcached_do(instance, buffer, send_length, true); + rc= memcached_do(instance, buffer, (size_t)send_length, true); if (rc != MEMCACHED_SUCCESS) goto error;