tests/mem_functions.cc
/*
  Test values of many different sizes
  Bug found where command total one more than MEMCACHED_MAX_BUFFER
  set key34567890 0 0 8169 \r\n
  is sent followed by buffer of size 8169, followed by 8169
 */
Test values of many different sizes
Bug found where command total one more than MEMCACHED_MAX_BUFFER
set key34567890 0 0 8169 \r\n
is sent followed by buffer of size 8169, followed by 8169
Test values of many different sizes Bug found where command total one more than MEMCACHED_MAX_BUFFER set key34567890 0 0 8169 \ r \ n is sent followed by buffer of size 8169 followed by 8169
static test_return_t user_supplied_bug14(memcached_st *memc)
{
  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true);
  std::vector<char> value;
  for (size_t x= 0; x < 18000; x++)
  {
    value.push_back((char) (x % 127));
  }
  for (size_t current_length= 0; current_length < value.size(); current_length++)
  {
    memcached_return_t rc= memcached_set(memc, test_literal_param("foo"),
                                         &value[0], current_length,
                                         (time_t)0, (uint32_t)0);
    test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
    size_t string_length;
    uint32_t flags;
    char *string= memcached_get(memc, test_literal_param("foo"),
                                &string_length, &flags, &rc);
    test_compare(MEMCACHED_SUCCESS, rc);
    test_compare(string_length, current_length);
    test_memcmp(string, &value[0], string_length);
    free(string);
  }
  return TEST_SUCCESS;
}
static test_return_t user_supplied_bug14 ( memcached_st * memc ) { memcached_behavior_set ( memc , MEMCACHED_BEHAVIOR_TCP_NODELAY , true ) ; std :: vector < char > value ; for ( size_t x = 0 ; x < 18000 ; x ++ ) { value . push_back ( ( char ) ( x % 127 ) ) ; } for ( size_t current_length = 0 ; current_length < value . size ( ) ; current_length ++ ) { memcached_return_t rc = memcached_set ( memc , test_literal_param ( " " ) , & value [ 0 ] , current_length , ( time_t ) 0 , ( uint32_t ) 0 ) ; test_true ( rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED ) ; size_t string_length ; uint32_t flags ; char * string = memcached_get ( memc , test_literal_param ( " " ) , & string_length , & flags , & rc ) ; test_compare ( MEMCACHED_SUCCESS , rc ) ; test_compare ( string_length , current_length ) ; test_memcmp ( string , & value [ 0 ] , string_length ) ; free ( string ) ; } return TEST_SUCCESS ; }
Test values of many different sizes
Bug found where command total one more than MEMCACHED_MAX_BUFFER
set key34567890 0 0 8169 \r\n
is sent followed by buffer of size 8169, followed by 8169
Test values of many different sizes Bug found where command total one more than MEMCACHED_MAX_BUFFER set key34567890 0 0 8169 \ r \ n is sent followed by buffer of size 8169 followed by 8169