]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use static buffer for tags names normalisation
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Jun 2021 13:14:57 +0000 (14:14 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Jun 2021 13:14:57 +0000 (14:14 +0100)
src/libserver/html/html.cxx

index a55266b196e7c69cf12297127a3eee66e08523bf..f0315434a0d3b281535bb909f96ed1a6c1d3020b 100644 (file)
@@ -466,13 +466,16 @@ html_parse_tag_content(rspamd_mempool_t *pool,
                        }
                        else {
                                /*
-                                * Copy tag name to the temporary buffer for modifications
+                                * Copy tag name to the temporary buffer for modifications.
+                                * We use static buffer as legit tag names are usually short enough
+                                * to save some space in memory pool.
                                 */
-                               auto *s = rspamd_mempool_alloc_buffer(pool, tag_name_len + 1);
-                               rspamd_strlcpy(s, parser_env.tag_name_start, tag_name_len + 1);
-                               auto nsize = rspamd_html_decode_entitles_inplace(s,
-                                               tag_name_len);
-                               nsize =  rspamd_str_lc_utf8(s, nsize);
+                               char s[32];
+
+                               auto nsize = rspamd_strlcpy(s, parser_env.tag_name_start,
+                                               MIN(sizeof(s), tag_name_len + 1));
+                               nsize = rspamd_html_decode_entitles_inplace(s, nsize);
+                               nsize = rspamd_str_lc_utf8(s, nsize);
 
                                const auto *tag_def = rspamd::html::html_tags_defs.by_name({s, nsize});