Browse Source

[Minor] One more mkstemp usage

tags/3.5
Vsevolod Stakhov 1 year ago
parent
commit
b13a39610c
No account linked to committer's email address
2 changed files with 7 additions and 8 deletions
  1. 3
    4
      src/libserver/maps/map_helpers.c
  2. 4
    4
      src/libserver/re_cache.c

+ 3
- 4
src/libserver/maps/map_helpers.c View File

@@ -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",

+ 4
- 4
src/libserver/re_cache.c View File

@@ -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)) {

Loading…
Cancel
Save