aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-08-31 16:44:49 +0100
committerGitHub <noreply@github.com>2021-08-31 16:44:49 +0100
commit760522c4da986f19e864da6123ba938f5e7d25d2 (patch)
tree08cec263b9abb9b6079141b3adf091c47254cc02 /src/lua
parentb17f6c211391d8892e04b402528acf2efc2fa81a (diff)
parentabea3ac21f764658a966dad475fc99e4b79530d7 (diff)
downloadrspamd-760522c4da986f19e864da6123ba938f5e7d25d2.tar.gz
rspamd-760522c4da986f19e864da6123ba938f5e7d25d2.zip
Merge pull request #3873 from jendis/fix_fuzzy_crash
[Fix] src/lua/lua_mimepart.c: fix null dereference
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_mimepart.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index 66b588e3a..21a46d496 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -1240,7 +1240,16 @@ lua_textpart_get_fuzzy_hashes (lua_State * L)
rspamd_stat_token_t *word;
struct lua_shingle_filter_cbdata cbd;
- if (part && pool) {
+
+ if (part == NULL || pool == NULL) {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ if (IS_TEXT_PART_EMPTY (part) || part->utf_words == NULL) {
+ lua_pushnil (L);
+ lua_pushnil (L);
+ }
+ else {
/* TODO: add keys and algorithms support */
rspamd_cryptobox_hash (key, "rspamd", strlen ("rspamd"), NULL, 0);
@@ -1294,9 +1303,6 @@ lua_textpart_get_fuzzy_hashes (lua_State * L)
}
}
}
- else {
- return luaL_error (L, "invalid arguments");
- }
return 2;
}