summaryrefslogtreecommitdiffstats
path: root/src/libmime/scan_result.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-06 15:39:47 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-06 15:39:47 +0000
commitd17a92c24e9d231bb1efe13d4e91280158301b7b (patch)
tree5a3f438192634fd0474627c5d5018db3c15a7bc0 /src/libmime/scan_result.c
parente7fbeb63bbe0a9275380910eef9b7dc01db18c5d (diff)
downloadrspamd-d17a92c24e9d231bb1efe13d4e91280158301b7b.tar.gz
rspamd-d17a92c24e9d231bb1efe13d4e91280158301b7b.zip
[Fix] Avoid strdup usage for symbols options
Diffstat (limited to 'src/libmime/scan_result.c')
-rw-r--r--src/libmime/scan_result.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index 671e99a9b..b9eb882b2 100644
--- a/src/libmime/scan_result.c
+++ b/src/libmime/scan_result.c
@@ -550,17 +550,18 @@ rspamd_task_add_result_option (struct rspamd_task *task,
k = kh_get (rspamd_options_hash, s->options, &srch);
if (k == kh_end (s->options)) {
- opt = rspamd_mempool_alloc0 (task->task_pool, sizeof (*opt));
+ gchar *dst_cpy;
- if (opt_cpy == NULL) {
- opt_cpy = rspamd_mempool_strdup (task->task_pool, val);
- }
+ opt = rspamd_mempool_alloc0 (task->task_pool,
+ sizeof (*opt) + vlen + 1);
+ dst_cpy = ((gchar *)opt) + sizeof (*opt);
+ memcpy (dst_cpy, val, vlen);
+ dst_cpy[vlen] = '\0';
opt->optlen = vlen;
- opt->option = opt_cpy;
+ opt->option = dst_cpy;
- k = kh_put (rspamd_options_hash, s->options, opt, &r);
- opt->option = opt_cpy;
+ kh_put (rspamd_options_hash, s->options, opt, &r);
DL_APPEND (s->opts_head, opt);
ret = TRUE;