string_ptr+= 6; /* "VALUE " */
+ // Just used for cases of AES decrypt currently
+ memcached_return_t rc= MEMCACHED_SUCCESS;
+
/* We load the key */
{
char *key= result->item_key;
result->key_length= 0;
- for (size_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++)
+ for (ptrdiff_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++)
{
if (prefix_length == 0)
{
memcached_string_set_length(&result->value, value_length);
}
- return MEMCACHED_SUCCESS;
+ if (memcached_is_encrypted(instance->root) and memcached_result_length(result))
+ {
+ hashkit_string_st *destination;
+
+ if ((destination= hashkit_decrypt(&instance->root->hashkit,
+ memcached_result_value(result), memcached_result_length(result))) == NULL)
+ {
+ rc= memcached_set_error(*instance->root, MEMCACHED_FAILURE,
+ MEMCACHED_AT, memcached_literal_param("hashkit_decrypt() failed"));
+ }
+ else
+ {
+ memcached_result_reset_value(result);
+ if (memcached_failed(memcached_result_set_value(result, hashkit_string_c_str(destination), hashkit_string_length(destination))))
+ {
+ rc= memcached_set_error(*instance->root, MEMCACHED_FAILURE,
+ MEMCACHED_AT, memcached_literal_param("hashkit_decrypt() failed"));
+ }
+ }
+
+ if (memcached_failed(rc))
+ {
+ memcached_result_reset(result);
+ }
+ hashkit_string_free(destination);
+ }
+
+ return rc;
read_error:
memcached_io_reset(instance);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
}
instance->major_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
}
instance->minor_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
}
instance->micro_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
}
instance->major_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
}
instance->minor_version= uint8_t(version);
if (errno == ERANGE)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
}
instance->micro_version= uint8_t(version);
}
else
{
rc= textual_read_one_response(instance, buffer, buffer_length, result);
- assert(rc != MEMCACHED_PROTOCOL_ERROR);
}
if (memcached_fatal(rc))