aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-11-16 18:10:12 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-11-16 18:10:12 +0000
commita282883e6f9d70a787970e92dc3d7644661cd8a3 (patch)
tree64914eebae467c1ccf4ebe256ae951c88b18c00c /src
parent0806e4d11bcc08bdc3b8efbf55c372f844b0a722 (diff)
downloadrspamd-a282883e6f9d70a787970e92dc3d7644661cd8a3.tar.gz
rspamd-a282883e6f9d70a787970e92dc3d7644661cd8a3.zip
[Minor] Some more fixes
Diffstat (limited to 'src')
-rw-r--r--src/libmime/mime_headers.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 3565eefba..e4d2ca458 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -818,7 +818,7 @@ rspamd_mime_header_decode(rspamd_mempool_t *pool, const char *in,
char *
rspamd_mime_header_encode(const char *in, gsize len)
{
- static const size_t max_token_size = 76 - (sizeof("=?UTF-8?Q? ?=") - 3);
+ static const size_t max_token_size = 76 - 12; /* 12 is the length of "=?UTF-8?Q??="; */
GString *outbuf = g_string_sized_new(len);
char *encode_buf = g_alloca(max_token_size + 3);
const char *p = in;
@@ -844,7 +844,7 @@ rspamd_mime_header_encode(const char *in, gsize len)
encoded_len += 3;
if (encoded_len > max_token_size) {
- piece_len = i - 1;
+ piece_len = i;
q = p + piece_len;
/* No more space */
break;
@@ -854,7 +854,7 @@ rspamd_mime_header_encode(const char *in, gsize len)
encoded_len++;
if (encoded_len > max_token_size) {
- piece_len = i - 1;
+ piece_len = i;
q = p + piece_len;
/* No more space */
break;
@@ -865,7 +865,7 @@ rspamd_mime_header_encode(const char *in, gsize len)
if (has_non_ascii) {
g_string_append(outbuf, "=?UTF-8?Q?");
/* Do encode */
- encoded_len = rspamd_encode_qp2047_buf(p, piece_len, encode_buf, max_token_size);
+ encoded_len = rspamd_encode_qp2047_buf(p, piece_len, encode_buf, max_token_size + 3);
g_string_append_len(outbuf, encode_buf, encoded_len);
g_string_append(outbuf, "?=");
}