commit 89f17f7: [Minor] Fix empty cache filename case
Vsevolod Stakhov
vsevolod at rspamd.com
Mon May 2 19:21:05 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-05-02 20:13:56 +0100
URL: https://github.com/rspamd/rspamd/commit/89f17f72d353f89cbf78d9a8bfcaa1d445519f73 (HEAD -> master)
[Minor] Fix empty cache filename case
---
src/libserver/symcache/symcache_impl.cxx | 4 ++++
src/libutil/cxx/locked_file.cxx | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx
index 0878ae32b..6b1802d96 100644
--- a/src/libserver/symcache/symcache_impl.cxx
+++ b/src/libserver/symcache/symcache_impl.cxx
@@ -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);
diff --git a/src/libutil/cxx/locked_file.cxx b/src/libutil/cxx/locked_file.cxx
index 13406c6cf..6abc4a1b0 100644
--- a/src/libutil/cxx/locked_file.cxx
+++ b/src/libutil/cxx/locked_file.cxx
@@ -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);
More information about the Commits
mailing list