]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use mkstemp for temporary hyperscan cache file
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 4 Mar 2023 12:34:41 +0000 (12:34 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 4 Mar 2023 12:34:41 +0000 (12:34 +0000)
src/libutil/multipattern.c

index e39374d4200e8778b1a750b1032d199b260185e0..f8df8a18644e44367b479c1759b4de63f8c71037 100644 (file)
@@ -426,10 +426,10 @@ rspamd_multipattern_try_save_hs (struct rspamd_multipattern *mp,
                return;
        }
 
-       rspamd_snprintf (fp, sizeof (fp), "%s/%*xs.hsmp.tmp", hs_cache_dir,
-                       (gint)rspamd_cryptobox_HASHBYTES / 2, hash);
+       rspamd_snprintf (fp, sizeof (fp), "%s%shsmp-XXXXXXXXXXXXX", G_DIR_SEPARATOR_S,
+               hs_cache_dir);
 
-       if ((fd = rspamd_file_xopen (fp, O_WRONLY | O_CREAT | O_EXCL, 00644, 1)) != -1) {
+       if ((fd = g_mkstemp_full(fp, O_CREAT|O_EXCL|O_WRONLY, 00644)) != -1) {
                int ret;
                if ((ret = hs_serialize_database (rspamd_hyperscan_get_database(mp->hs_db), &bytes, &len)) == HS_SUCCESS) {
                        if (write (fd, bytes, len) == -1) {