X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcachedprotocol%2Fascii_handler.c;h=449b650d7e8e9f5b46fd2373c98b705f6b82254d;hb=88b1aa19c0b3c5ad047222618cb17f447ea2bc67;hp=8cd29720bae5c7c681d95eb974793a12176ec6fc;hpb=b43d7591dbe31dedd9fed41f01d07e8a3412582b;p=awesomized%2Flibmemcached diff --git a/libmemcachedprotocol/ascii_handler.c b/libmemcachedprotocol/ascii_handler.c index 8cd29720..449b650d 100644 --- a/libmemcachedprotocol/ascii_handler.c +++ b/libmemcachedprotocol/ascii_handler.c @@ -561,7 +561,12 @@ static void process_arithmetic(memcached_protocol_client_st *client, uint64_t cas; uint64_t result; + errno= 0; uint64_t delta= strtoull(tokens[2], NULL, 10); + if (errno != 0) + { + return; // Error + } protocol_binary_response_status rval; if (client->ascii_command == INCR_CMD) @@ -667,7 +672,12 @@ static void process_flush(memcached_protocol_client_st *client, uint32_t timeout= 0; if (ntokens == 2) { + errno= 0; timeout= (uint32_t)strtoul(tokens[1], NULL, 10); + if (errno != 0) + { + return; // Error + } } protocol_binary_response_status rval; @@ -706,9 +716,30 @@ static inline int process_storage_command(memcached_protocol_client_st *client, return -1; } + errno= 0; uint32_t flags= (uint32_t)strtoul(tokens[2], NULL, 10); + if (errno != 0) + { + /* return error */ + raw_response_handler(client, "CLIENT_ERROR: bad key\r\n"); + return -1; + } + uint32_t timeout= (uint32_t)strtoul(tokens[3], NULL, 10); + if (errno != 0) + { + /* return error */ + raw_response_handler(client, "CLIENT_ERROR: bad key\r\n"); + return -1; + } + unsigned long nbytes= strtoul(tokens[4], NULL, 10); + if (errno != 0) + { + /* return error */ + raw_response_handler(client, "CLIENT_ERROR: bad key\r\n"); + return -1; + } /* Do we have all data? */ unsigned long need= nbytes + (unsigned long)((*end - start) + 1) + 2; /* \n\r\n */ @@ -743,7 +774,14 @@ static inline int process_storage_command(memcached_protocol_client_st *client, timeout, &result_cas); break; case CAS_CMD: + errno= 0; cas= strtoull(tokens[5], NULL, 10); + if (errno != 0) + { + /* return error */ + raw_response_handler(client, "CLIENT_ERROR: bad key\r\n"); + return -1; + } /* FALLTHROUGH */ case REPLACE_CMD: rval= client->root->callback->interface.v1.replace(client, key,