]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] src/lua/lua_mimepart.c: fix null dereference 3873/head
authorJan Smutny <js@excello.cz>
Tue, 31 Aug 2021 12:25:23 +0000 (14:25 +0200)
committerJan Smutny <js@excello.cz>
Tue, 31 Aug 2021 12:36:36 +0000 (14:36 +0200)
src/lua/lua_mimepart.c

index 66b588e3aa81cfa7324744d411f15e67cb1c7e34..21a46d496e848fc6b4284749a8bcfa35c68c6e95 100644 (file)
@@ -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;
 }