]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Allow partial hash updates
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 May 2016 09:51:36 +0000 (10:51 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 May 2016 09:51:36 +0000 (10:51 +0100)
src/lua/lua_cryptobox.c

index b95b1f2f6224d2ea06c0c4062e1b3a7276babcf1..7f267fe71d081fa453cb7b78518dbb3fd7973636 100644 (file)
@@ -662,6 +662,17 @@ lua_cryptobox_hash_update (lua_State *L)
                data = luaL_checklstring (L, 2, &len);
        }
 
+       if (lua_isnumber (L, 3)) {
+               gsize nlen = lua_tonumber (L, 3);
+
+               if (nlen > len) {
+                       return luaL_error (L, "invalid length: %d while %d is available",
+                                       (int)nlen, (int)len);
+               }
+
+               len = nlen;
+       }
+
        if (h && data) {
                rspamd_cryptobox_hash_update (h, data, len);
        }