From: Date: Mon, 3 Dec 2007 00:17:05 +0000 (+0900) Subject: Fixed problem with out of range character in key. X-Git-Tag: 0.13~54 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ce94a18ec36e050c0afb49a8c6fba022e5bb82ee;p=awesomized%2Flibmemcached Fixed problem with out of range character in key. --- diff --git a/ChangeLog b/ChangeLog index 35814be1..cb53ed89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ * Refactor of memcached_get() to use common code. * Change in value fetch, MEMCACHED_END is now returned when keys are no longer in the pipe. - + * Fixed bug where key could be out of range of characters 0.11 Mon Nov 26 01:05:52 PST 2007 * Added option to memcache_behavior_set() so that poll() can be timed out. diff --git a/lib/memcached.c b/lib/memcached.c index b474ca5d..591bf1f6 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -48,7 +48,7 @@ void memcached_free(memcached_st *ptr) */ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) { - memcached_return rc; + memcached_return rc= MEMCACHED_SUCCESS; memcached_st *new_clone; if (ptr == NULL) diff --git a/lib/memcached_fetch.c b/lib/memcached_fetch.c index ac4f4911..b8954748 100644 --- a/lib/memcached_fetch.c +++ b/lib/memcached_fetch.c @@ -35,7 +35,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size { *key_length= 0; - for (; isalnum(*string_ptr); string_ptr++) + for (; isgraph(*string_ptr); string_ptr++) { *key= *string_ptr; key++; @@ -43,7 +43,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size } } else /* Skip characters */ - for (; isalnum(*string_ptr); string_ptr++); + for (; isgraph(*string_ptr); string_ptr++); if (end_ptr == string_ptr) goto read_error; diff --git a/tests/function.c b/tests/function.c index 2450b0dd..34082966 100644 --- a/tests/function.c +++ b/tests/function.c @@ -1343,6 +1343,49 @@ uint8_t user_supplied_bug7(memcached_st *memc) return 0; } +uint8_t user_supplied_bug9(memcached_st *memc) +{ + memcached_return rc; + char *keys[]= {"UDATA:edevil@sapo.pt", "fudge&*@#", "for^#@&$not"}; + size_t key_length[3]; + unsigned int x; + uint16_t flags; + unsigned count= 0; + + char return_key[MEMCACHED_MAX_KEY]; + size_t return_key_length; + char *return_value; + size_t return_value_length; + + + key_length[0]= strlen("UDATA:edevil@sapo.pt"); + key_length[1]= strlen("fudge&*@#"); + key_length[2]= strlen("for^#@&$not"); + + + for (x= 0; x < 3; x++) + { + rc= memcached_set(memc, keys[x], key_length[x], + keys[x], key_length[x], + (time_t)50, (uint16_t)9); + assert(rc == MEMCACHED_SUCCESS); + } + + rc= memcached_mget(memc, keys, key_length, 3); + assert(rc == MEMCACHED_SUCCESS); + + /* We need to empty the server before continueing test */ + while ((return_value= memcached_fetch(memc, return_key, &return_key_length, + &return_value_length, &flags, &rc)) != NULL) + { + assert(return_value); + count++; + } + assert(count == 3); + + return 0; +} + uint8_t result_static(memcached_st *memc) { memcached_result_st result; @@ -1838,6 +1881,7 @@ test_st user_tests[] ={ {"user_supplied_bug6", 1, user_supplied_bug6 }, {"user_supplied_bug7", 1, user_supplied_bug7 }, {"user_supplied_bug8", 1, user_supplied_bug8 }, + {"user_supplied_bug9", 1, user_supplied_bug9 }, {0, 0, 0} };