commit a52e519: [Minor] Fix extensions processing in fuzzy worker

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 8 13:49:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-07-08 14:44:47 +0100
URL: https://github.com/rspamd/rspamd/commit/a52e5197df22659df1f611ce4505c505b461b365 (HEAD -> master)

[Minor] Fix extensions processing in fuzzy worker

---
 src/fuzzy_storage.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 0d7721ffb..f9c669452 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -1118,12 +1118,12 @@ rspamd_fuzzy_command_valid (struct rspamd_fuzzy_cmd *cmd, gint r)
 	switch (cmd->version) {
 	case 4:
 		if (cmd->shingles_count > 0) {
-			if (r == sizeof (struct rspamd_fuzzy_shingle_cmd)) {
+			if (r >= sizeof (struct rspamd_fuzzy_shingle_cmd)) {
 				ret = RSPAMD_FUZZY_EPOCH11;
 			}
 		}
 		else {
-			if (r == sizeof (*cmd)) {
+			if (r >= sizeof (*cmd)) {
 				ret = RSPAMD_FUZZY_EPOCH11;
 			}
 		}
@@ -1223,7 +1223,7 @@ rspamd_fuzzy_decrypt_command (struct fuzzy_session *s, guchar *buf, gsize buflen
 static gboolean
 rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize buflen)
 {
-	struct rspamd_fuzzy_cmd_extension *ext;
+	struct rspamd_fuzzy_cmd_extension *ext, *prev_ext;
 	guchar *storage, *p = buf, *end = buf + buflen;
 	gsize st_len = 0, n_ext = 0;
 
@@ -1295,6 +1295,7 @@ rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize b
 
 		/* All validation has been done, so we can just go further */
 		while (p < end) {
+			prev_ext = ext;
 			guchar cmd = *p++;
 
 			if (cmd == RSPAMD_FUZZY_EXT_SOURCE_DOMAIN) {
@@ -1338,7 +1339,7 @@ rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize b
 		}
 
 		/* Last next should be NULL */
-		ext->next = NULL;
+		prev_ext->next = NULL;
 
 		/* Rewind to the begin */
 		ext = (struct rspamd_fuzzy_cmd_extension *)storage;


More information about the Commits mailing list