From e369efa91be624f2c5134f89744aa7ca7ea3fee7 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 24 Jan 2020 17:33:25 +0000 Subject: [PATCH] [Minor] Fix masks calculations --- src/libutil/radix.c | 6 +++--- test/functional/lua/maps_kv.lua | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libutil/radix.c b/src/libutil/radix.c index bdca39aab..81f929731 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -302,7 +302,7 @@ rspamd_radix_add_iplist (const gchar *list, const gchar *separators, radix_insert_compressed (tree, addr_buf.buf, sizeof (addr_buf.buf), - 128 - k, (uintptr_t)value); + 32 - k, (uintptr_t)value); res ++; } else if (cur_ai->ai_family == AF_INET6) { @@ -348,12 +348,12 @@ rspamd_radix_add_iplist (const gchar *list, const gchar *separators, } /* Move to the last part of the address */ - memmove (addr_buf.buf, addr_buf.buf + 12, 4); + memmove (addr_buf.buf + 12, &addr_buf.ina, 4); memset (addr_buf.buf, 0, 10); addr_buf.buf[10] = 0xffu; addr_buf.buf[11] = 0xffu; radix_insert_compressed (tree, addr_buf.buf, sizeof (addr_buf.buf), - 128 - k, (uintptr_t)value); + 32 - k, (uintptr_t)value); res ++; } else if (af == AF_INET6){ diff --git a/test/functional/lua/maps_kv.lua b/test/functional/lua/maps_kv.lua index 3decc48c2..b63b32c34 100644 --- a/test/functional/lua/maps_kv.lua +++ b/test/functional/lua/maps_kv.lua @@ -26,11 +26,11 @@ rspamd_config:register_symbol({ if (radix_map:get_key(rspamd_ip.from_string(sip[i])) ~= expected[i]) then local rip = rspamd_ip.from_string(sip[i]) local val = radix_map:get_key(rip) - return true, rspamd_logger.slog('get_key(%s) [%s] -> %s [%s] [expected %s]', rip, type(rip), val, type(val), expected[i]) + return true, rspamd_logger.slog('plain: get_key(%s) [%s] -> %s [%s] [expected %s]', rip, type(rip), val, type(val), expected[i]) end if (radix_map:get_key(sip[i]) ~= expected[i]) then local val = radix_map:get_key(sip[i]) - return true, rspamd_logger.slog('get_key(%s) [%s] -> %s [%s] [expected %s]', sip[i], type(sip[i]), val, type(val), expected[i]) + return true, rspamd_logger.slog('string: get_key(%s) [%s] -> %s [%s] [expected %s]', sip[i], type(sip[i]), val, type(val), expected[i]) end end return true, 'no worry' -- 2.39.5