commit 56129a4: [Minor] Return nil if base32 decode fails
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Jul 2 15:49:07 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-07-02 16:42:48 +0100
URL: https://github.com/rspamd/rspamd/commit/56129a44f9f72091ab2b500746f3d0a47ee88b5c (HEAD -> master)
[Minor] Return nil if base32 decode fails
---
src/lua/lua_util.c | 19 ++++++++++++++-----
1 file 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);
More information about the Commits
mailing list