From 7d40adf82d014bc25de73708ac5c528dc8115f90 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 8 Mar 2018 17:07:53 +0000 Subject: [PATCH] [Minor] Fix string copy --- src/libmime/content_type.c | 4 ++-- src/libutil/str_util.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c index 946a9b838..bcb047898 100644 --- a/src/libmime/content_type.c +++ b/src/libmime/content_type.c @@ -502,8 +502,8 @@ rspamd_content_disposition_parse (const gchar *in, { struct rspamd_content_disposition *res = NULL, val; - val.lc_data = rspamd_mempool_alloc (pool, len); - memcpy (val.lc_data, in, len); + val.lc_data = rspamd_mempool_alloc (pool, len + 1); + rspamd_strlcpy (val.lc_data, in, len); rspamd_str_lc (val.lc_data, len); if (rspamd_content_disposition_parser (in, len, &val, pool)) { diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index 69b17fb4f..c111b0a96 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -79,10 +79,12 @@ rspamd_str_lc (gchar *str, guint size) switch (leftover) { case 3: *dest++ = lc_map[(guchar)str[i++]]; + /* falltrough */ case 2: *dest++ = lc_map[(guchar)str[i++]]; + /* falltrough */ case 1: - *dest++ = lc_map[(guchar)str[i]]; + *dest = lc_map[(guchar)str[i]]; } } -- 2.39.5