From 93022e6207ed15f8dd231ad43511d7c9e3f2eee8 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 16 Jul 2022 23:50:13 +0100 Subject: [PATCH] [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) -- 2.39.5