summaryrefslogtreecommitdiffstats
path: root/src/libutil/cxx/file_util.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/cxx/file_util.cxx')
-rw-r--r--src/libutil/cxx/file_util.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libutil/cxx/file_util.cxx b/src/libutil/cxx/file_util.cxx
index e5286a2cd..317683370 100644
--- a/src/libutil/cxx/file_util.cxx
+++ b/src/libutil/cxx/file_util.cxx
@@ -368,12 +368,22 @@ TEST_CASE("check lock") {
CHECK(serrno == ENOENT);
}
-auto get_tmpdir() -> const char * {
+auto get_tmpdir() -> std::string {
const auto *tmpdir = getenv("TMPDIR");
if (tmpdir == nullptr) {
tmpdir = G_DIR_SEPARATOR_S "tmp";
}
- return tmpdir;
+
+ std::size_t sz;
+ std::string mut_fname = tmpdir;
+ rspamd_normalize_path_inplace(mut_fname.data(), mut_fname.size(), &sz);
+ mut_fname.resize(sz);
+
+ if (!mut_fname.ends_with(G_DIR_SEPARATOR)) {
+ mut_fname += G_DIR_SEPARATOR;
+ }
+
+ return mut_fname;
}
TEST_CASE("tempfile") {