]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix empty cache filename case
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 2 May 2022 19:13:56 +0000 (20:13 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 2 May 2022 19:13:56 +0000 (20:13 +0100)
src/libserver/symcache/symcache_impl.cxx
src/libutil/cxx/locked_file.cxx

index 0878ae32b5629aa2c7ac14eabed0b955080560ec..6b1802d964c5fdb7f1d8c744e08c363880307b23 100644 (file)
@@ -258,6 +258,10 @@ static constexpr auto round_to_hundreds(T x)
 
 bool symcache::save_items() const
 {
+       if (cfg->cache_filename == nullptr) {
+               return false;
+       }
+
        auto file_sink = util::raii_file_sink::create(cfg->cache_filename,
                        O_WRONLY | O_TRUNC, 00644);
 
index 13406c6cfc4c72cdfd52dcb2f533f6cdd2de2f99..6abc4a1b0dd67dc37efcaa13311c2c3bc0325d4a 100644 (file)
@@ -176,6 +176,10 @@ raii_mmaped_locked_file::raii_mmaped_locked_file(raii_mmaped_locked_file &&other
 auto raii_file_sink::create(const char *fname, int flags, int perms,
                                                        const char *suffix) -> tl::expected<raii_file_sink, std::string>
 {
+       if (!fname || !suffix) {
+               return tl::make_unexpected("cannot create file sink: bad input arguments");
+       }
+
        auto tmp_fname = fmt::format("{}.{}", fname, suffix);
        auto file = raii_locked_file::create(tmp_fname.c_str(), flags, perms);