diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-16 13:17:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-16 13:17:08 +0100 |
commit | c85f7833d8eac693b0a67440a19b0c8b66e61b46 (patch) | |
tree | cf5d44e43b7bbca6cf07021043b4ea93be87940f /src/libmime/archives.c | |
parent | 16190652c032e771fb2d6677491a1c16762b56ff (diff) | |
download | rspamd-c85f7833d8eac693b0a67440a19b0c8b66e61b46.tar.gz rspamd-c85f7833d8eac693b0a67440a19b0c8b66e61b46.zip |
[Fix] Fix size calculations when converting from utf16
Diffstat (limited to 'src/libmime/archives.c')
-rw-r--r-- | src/libmime/archives.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libmime/archives.c b/src/libmime/archives.c index cc81326ec..f3ad60067 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -1439,14 +1439,16 @@ rspamd_7zip_ucs2_to_utf8 (struct rspamd_task *task, const guchar *p, UChar32 wc; UBool is_error = 0; - res = g_string_sized_new ((end - p) + sizeof (wc) * 2 + 1); + res = g_string_sized_new ((end - p) * 1.5 + sizeof (wc) + 1); up = (guint16 *)p; while (src_pos < len) { U16_NEXT (up, src_pos, len, wc); if (wc > 0) { - U8_APPEND (res->str, dest_pos, res->allocated_len, wc, is_error); + U8_APPEND (res->str, dest_pos, + res->allocated_len - 1, + wc, is_error); } if (is_error) { |