aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-07-02 16:42:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-07-02 16:42:48 +0100
commit56129a44f9f72091ab2b500746f3d0a47ee88b5c (patch)
treefa02a467e54201e4addd73100295229a12cc6576 /src
parent34c6bcc9e1702bd74de5eb2f9c5a52d431c600e0 (diff)
downloadrspamd-56129a44f9f72091ab2b500746f3d0a47ee88b5c.tar.gz
rspamd-56129a44f9f72091ab2b500746f3d0a47ee88b5c.zip
[Minor] Return nil if base32 decode fails
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_util.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 70236fc2f..d81c574b7 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -1232,11 +1232,20 @@ lua_util_decode_base32 (lua_State *L)
}
if (s != NULL) {
- t = lua_newuserdata (L, sizeof (*t));
- rspamd_lua_setclass (L, "rspamd{text}", -1);
- t->start = rspamd_decode_base32 (s, inlen, &outlen, btype);
- t->len = outlen;
- t->flags = RSPAMD_TEXT_FLAG_OWN;
+ guchar *decoded;
+
+ decoded = rspamd_decode_base32 (s, inlen, &outlen, btype);
+
+ if (decoded) {
+ t = lua_newuserdata (L, sizeof (*t));
+ rspamd_lua_setclass (L, "rspamd{text}", -1);
+ t->start = (const gchar *)decoded;
+ t->len = outlen;
+ t->flags = RSPAMD_TEXT_FLAG_OWN;
+ }
+ else {
+ lua_pushnil (L);
+ }
}
else {
lua_pushnil (L);