From f00605dce4a482c8b19ef17c0e79c31238498522 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 14 Jan 2020 15:35:57 +0100 Subject: [PATCH] libmemcachedutil: fix version check --- libmemcachedutil/version.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libmemcachedutil/version.cc b/libmemcachedutil/version.cc index 0fcfb5c5..75a8f60e 100644 --- a/libmemcachedutil/version.cc +++ b/libmemcachedutil/version.cc @@ -55,12 +55,20 @@ static memcached_return_t check_server_version(const memcached_st *, /* Do Nothing */ struct local_context *check= (struct local_context *)context; - if (memcached_server_major_version(instance) != UINT8_MAX && - memcached_server_major_version(instance) >= check->major_version and - memcached_server_minor_version(instance) >= check->minor_version and - memcached_server_micro_version(instance) >= check->micro_version ) - { - return MEMCACHED_SUCCESS; + if (memcached_server_major_version(instance) != UINT8_MAX) { + uint32_t sv, cv; + + sv = memcached_server_micro_version(instance) + |memcached_server_minor_version(instance) << 8 + |memcached_server_major_version(instance) << 16 + ; + cv = check->micro_version + |check->minor_version << 8 + |check->major_version << 16; + + if (sv >= cv) { + return MEMCACHED_SUCCESS; + } } check->truth= false; -- 2.30.2