]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix extensions calculations
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 20 Aug 2020 19:50:59 +0000 (20:50 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 20 Aug 2020 19:51:13 +0000 (20:51 +0100)
src/fuzzy_storage.c

index b8e3d49c2808fc250ff278fe4f259c44ab2c9378..f806cb87d42fea670838db403258ae3f5796b251 100644 (file)
@@ -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 */