X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fdump.c;h=9ec2dab5982ebbf46bce70dcbc8fa797dc198b48;hb=349ca737f30ff0b6c3c71034f0930660663fa360;hp=cd2489e076a64ec0e2dbd28009bb1ff91d077744;hpb=814d911f182e08fb4401df649270f5fff2e8ed4c;p=m6w6%2Flibmemcached diff --git a/libmemcached/dump.c b/libmemcached/dump.c index cd2489e0..9ec2dab5 100644 --- a/libmemcached/dump.c +++ b/libmemcached/dump.c @@ -11,7 +11,6 @@ static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callb { memcached_return_t rc= MEMCACHED_SUCCESS; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - size_t send_length; uint32_t server_key; uint32_t x; @@ -20,13 +19,22 @@ static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callb for (server_key= 0; server_key < memcached_server_count(ptr); server_key++) { + memcached_server_write_instance_st instance; + instance= memcached_server_instance_fetch(ptr, server_key); + /* 256 I BELIEVE is the upper limit of slabs */ for (x= 0; x < 256; x++) { - send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "stats cachedump %u 0 0\r\n", x); + int send_length; + send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, + "stats cachedump %u 0 0\r\n", x); + + if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) + { + return MEMCACHED_FAILURE; + } - rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1); + rc= memcached_do(instance, buffer, (size_t)send_length, true); unlikely (rc != MEMCACHED_SUCCESS) goto error; @@ -34,7 +42,7 @@ static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callb while (1) { uint32_t callback_counter; - rc= memcached_response(&ptr->hosts[server_key], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); + rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); if (rc == MEMCACHED_ITEM) {