]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix masks calculations
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 24 Jan 2020 17:33:25 +0000 (17:33 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 24 Jan 2020 17:33:25 +0000 (17:33 +0000)
src/libutil/radix.c
test/functional/lua/maps_kv.lua

index bdca39aab889cd8161a2b8a3cfd06659a9d149ab..81f929731c19391702dd092a5f54e8e9eb765135 100644 (file)
@@ -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){
index 3decc48c2f637fa1e419037a0f34d21db048f3d5..b63b32c34642314e0dbe86af5f5af02c1fc622ef 100644 (file)
@@ -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'