blob: d355f701a2731891fbd91ab112c915115a432033 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
From abea3ac21f764658a966dad475fc99e4b79530d7 Mon Sep 17 00:00:00 2001
From: Jan Smutny <js@excello.cz>
Date: Tue, 31 Aug 2021 14:25:23 +0200
Subject: [PATCH] [Fix] src/lua/lua_mimepart.c: fix null dereference
---
This patch is taken from upstream. It fixes possible runtime segfaults.
PR: https://github.com/rspamd/rspamd/pull/3873
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;
}
--
2.31.1
|