commit 93022e6: [Test] Check the decoded length when doing base32 fuzz test

Vsevolod Stakhov vsevolod at rspamd.com
Sat Jul 16 23:00:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-07-16 23:50:13 +0100
URL: https://github.com/rspamd/rspamd/commit/93022e6207ed15f8dd231ad43511d7c9e3f2eee8 (HEAD -> master)

[Test] Check the decoded length when doing base32 fuzz test

---
 test/lua/unit/base32.lua | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/lua/unit/base32.lua b/test/lua/unit/base32.lua
index a460b6575..d6e67c06a 100644
--- a/test/lua/unit/base32.lua
+++ b/test/lua/unit/base32.lua
@@ -33,7 +33,7 @@ context("Base32 encodning", function()
     end
   end)
 
-  test("Base32 fuzz test", function()
+  test("Base32 fuzz test: zbase32", function()
     for i = 1,1000 do
       local b, l = random_buf(4096)
       local how = math.floor(math.random(3) - 1)
@@ -42,6 +42,8 @@ context("Base32 encodning", function()
       local nl = ffi.new("size_t [1]")
       local nb = ffi.C.rspamd_decode_base32(bs, #bs, nl, how)
 
+      assert_equal(tonumber(nl[0]), l,
+          string.format("invalid size reported: %d reported vs %d expected", tonumber(nl[0]), l))
       local cmp = ffi.C.memcmp(b, nb, l)
       ffi.C.g_free(ben)
       ffi.C.g_free(nb)


More information about the Commits mailing list