commit b95a54e: [Minor] Fix extensions calculations

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Aug 20 19:56:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-08-20 20:50:59 +0100
URL: https://github.com/rspamd/rspamd/commit/b95a54eb684b318c37b1b108a94a6cbb721cf902

[Minor] Fix extensions calculations

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

diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index b8e3d49c2..f806cb87d 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -1249,7 +1249,6 @@ rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize b
 			}
 			else if (cmd == RSPAMD_FUZZY_EXT_SOURCE_IP4) {
 				if (end - p >= sizeof (in_addr_t)) {
-					p += sizeof (in_addr_t);
 					n_ext ++;
 					st_len += sizeof (in_addr_t);
 				}
@@ -1262,7 +1261,6 @@ rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize b
 			}
 			else if (cmd == RSPAMD_FUZZY_EXT_SOURCE_IP6) {
 				if (end - p >= sizeof (struct in6_addr)) {
-					p += sizeof (struct in6_addr);
 					n_ext ++;
 					st_len += sizeof (struct in6_addr);
 				}
@@ -1273,6 +1271,10 @@ rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize b
 
 				p += sizeof (struct in6_addr);
 			}
+			else {
+				/* Invalid command */
+				return FALSE;
+			}
 		}
 		else {
 			/* Truncated extension */
@@ -1336,6 +1338,9 @@ rspamd_fuzzy_extensions_from_wire (struct fuzzy_session *s, guchar *buf, gsize b
 				data_buf += sizeof (struct in6_addr);
 				ext = ext->next;
 			}
+			else {
+				g_assert_not_reached ();
+			}
 		}
 
 		/* Last next should be NULL */


More information about the Commits mailing list