aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-03-04 13:41:58 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-03-04 13:41:58 +0000
commitb13a39610c9007a1afa4d1dbf94d73a1a5b1269b (patch)
tree5d888f1c3c396e4ca8be6347b47990f664a9f1d1 /src
parent3d80e66c8f8b734208d0eed314b406f309173286 (diff)
downloadrspamd-b13a39610c9007a1afa4d1dbf94d73a1a5b1269b.tar.gz
rspamd-b13a39610c9007a1afa4d1dbf94d73a1a5b1269b.zip
[Minor] One more mkstemp usage
Diffstat (limited to 'src')
-rw-r--r--src/libserver/maps/map_helpers.c7
-rw-r--r--src/libserver/re_cache.c8
2 files changed, 7 insertions, 8 deletions
diff --git a/src/libserver/maps/map_helpers.c b/src/libserver/maps/map_helpers.c
index 2fa7743b4..a1052326c 100644
--- a/src/libserver/maps/map_helpers.c
+++ b/src/libserver/maps/map_helpers.c
@@ -1093,11 +1093,10 @@ rspamd_try_save_re_map_cache (struct rspamd_regexp_map_helper *re_map)
return FALSE;
}
- rspamd_snprintf (fp, sizeof (fp), "%s/%*xs.hsmc.tmp",
- re_map->map->cfg->hs_cache_dir,
- (gint)rspamd_cryptobox_HASHBYTES / 2, re_map->re_digest);
+ rspamd_snprintf (fp, sizeof (fp), "%s/hsmc-XXXXXXXXXXXXX",
+ re_map->map->cfg->hs_cache_dir);
- if ((fd = rspamd_file_xopen (fp, O_WRONLY | O_CREAT | O_EXCL, 00644, 0)) != -1) {
+ if ((fd = g_mkstemp_full(fp, O_WRONLY | O_CREAT | O_EXCL, 00644)) != -1) {
if (hs_serialize_database (rspamd_hyperscan_get_database(re_map->hs_db), &bytes, &len) == HS_SUCCESS) {
if (write (fd, bytes, len) == -1) {
msg_warn_map ("cannot write hyperscan cache to %s: %s",
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index c89536206..cbf76d1a9 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -1954,10 +1954,10 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
g_hash_table_iter_init (&cit, re_class->re);
n = g_hash_table_size (re_class->re);
- hs_flags = g_malloc0 (sizeof (*hs_flags) * n);
- hs_ids = g_malloc (sizeof (*hs_ids) * n);
- hs_pats = g_malloc (sizeof (*hs_pats) * n);
- hs_exts = g_malloc0 (sizeof (*hs_exts) * n);
+ hs_flags = g_new0(guint, n);
+ hs_ids = g_new0(guint, n);
+ hs_pats = g_new0(char *, n);
+ hs_exts = g_new0(const hs_expr_ext_t *, n);
i = 0;
while (g_hash_table_iter_next (&cit, &k, &v)) {