# ChangeLog v1.1
+## v 1.1.2
+
+> released 2022-08-08
+
+* Fix handling of negative expiration values, which are somehow allowed by legacy.
+ See also [gh #125](https://github.com/awesomized/libmemcached/issues/125),
+ and [gh #76](https://github.com/awesomized/libmemcached/issues/76).
+
## v 1.1.1
> released 2021-09-16
static memcached_return_t memcached_flush_textual(Memcached *ptr, time_t expiration,
const bool reply) {
- char buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH + 1];
+ char buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH + 1 + 1];
int send_length = 0;
if (expiration) {
- send_length = snprintf(buffer, sizeof(buffer), "%llu", (unsigned long long) expiration);
+ send_length = snprintf(buffer, sizeof(buffer), "%lld", (long long) expiration);
}
if (size_t(send_length) >= sizeof(buffer) or send_length < 0) {
memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)"));
}
- char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH + 1];
- int expiration_buffer_length = snprintf(expiration_buffer, sizeof(expiration_buffer), " %llu",
- (unsigned long long) expiration);
+ char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH + 1 + 1];
+ int expiration_buffer_length = snprintf(expiration_buffer, sizeof(expiration_buffer), " %lld",
+ (long long) expiration);
if (size_t(expiration_buffer_length) >= sizeof(expiration_buffer) or expiration_buffer_length < 0)
{
return memcached_set_error(
static memcached_return_t ascii_touch(memcached_instance_st *instance, const char *key,
size_t key_length, time_t expiration) {
- char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH + 1];
- int expiration_buffer_length = snprintf(expiration_buffer, sizeof(expiration_buffer), " %llu",
- (unsigned long long) expiration);
+ char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH + 1 + 1];
+ int expiration_buffer_length = snprintf(expiration_buffer, sizeof(expiration_buffer), " %lld",
+ (long long) expiration);
if (size_t(expiration_buffer_length) >= sizeof(expiration_buffer) + 1
or expiration_buffer_length < 0)
{
--- /dev/null
+#include "test/lib/common.hpp"
+#include "test/lib/MemcachedCluster.hpp"
+
+TEST_CASE("memcached_regression_gh_0125") {
+ auto test = MemcachedCluster::network();
+ auto memc = &test.memc;
+ auto blob = random_ascii_string(1024);
+ auto binary = GENERATE(0, 1);
+
+ test.enableBinaryProto(binary);
+ INFO("binary: " << binary);
+
+ memcached_return_t rc = memcached_set(memc, S("key"), blob.c_str(), blob.length(), -123, 0);
+ REQUIRE_SUCCESS(rc);
+}