diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-03-04 12:34:41 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-03-04 12:34:41 +0000 |
commit | f6dce922295bf141608c2509502615a36df6c960 (patch) | |
tree | e94155a718e2fda4a05c9411f123edbc4a1d6489 | |
parent | c0e967fcede63765cec4da3ce5cca047542cfc26 (diff) | |
download | rspamd-f6dce922295bf141608c2509502615a36df6c960.tar.gz rspamd-f6dce922295bf141608c2509502615a36df6c960.zip |
[Minor] Use mkstemp for temporary hyperscan cache file
-rw-r--r-- | src/libutil/multipattern.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c index e39374d42..f8df8a186 100644 --- a/src/libutil/multipattern.c +++ b/src/libutil/multipattern.c @@ -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) { |