]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Further key length optimization
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 10 Apr 2018 12:54:10 +0000 (13:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 10 Apr 2018 12:55:35 +0000 (13:55 +0100)
src/plugins/lua/ratelimit.lua

index 0706abc3ecdc7a2a867e3d784e893210f5f7e766..935a4a2474ef4c34898e8679a3ea03ad13acd9c7 100644 (file)
@@ -358,8 +358,10 @@ local function ratelimit_cb(task)
       local prefix = gen_rate_key(task, k, bucket)
 
       if prefix then
+        local hash_len = 24
+        if hash_len > #prefix then hash_len = #prefix end
         local hash = settings.prefix ..
-                string.sub(rspamd_hash.create(prefix):base32(), 1, 24)
+                string.sub(rspamd_hash.create(prefix):base32(), 1, hash_len)
         prefixes[prefix] = {
           bucket = bucket,
           name = k,