From: Vsevolod Stakhov Date: Tue, 3 May 2016 09:51:36 +0000 (+0100) Subject: [Feature] Allow partial hash updates X-Git-Tag: 1.3.0~573 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=773ef1f7414e60dfdd3a3ea73b89d9deda5e74d4;p=thirdparty%2Frspamd.git [Feature] Allow partial hash updates --- diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index b95b1f2f62..7f267fe71d 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -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); }