commit 34bb346: [Minor] Use static buffer for tags names normalisation
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jun 29 17:35:05 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-06-29 14:14:57 +0100
URL: https://github.com/rspamd/rspamd/commit/34bb346628f3fe3da1ab35700d238e29345a510a (HEAD -> master)
[Minor] Use static buffer for tags names normalisation
---
src/libserver/html/html.cxx | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index a55266b19..f0315434a 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -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});
More information about the Commits
mailing list