From: Vsevolod Stakhov Date: Sun, 23 Oct 2022 21:08:31 +0000 (+0100) Subject: [Minor] Normalise file names X-Git-Tag: 3.4~24 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=00c70303f6bcd0f1b778bf6647e1b049c5e27ea3;p=rspamd.git [Minor] Normalise file names --- diff --git a/src/libutil/cxx/file_util.cxx b/src/libutil/cxx/file_util.cxx index d0860b77b..1993ff666 100644 --- a/src/libutil/cxx/file_util.cxx +++ b/src/libutil/cxx/file_util.cxx @@ -145,6 +145,16 @@ auto raii_file::update_stat() noexcept -> bool return fstat(fd, &st) != -1; } +raii_file::raii_file(const char *fname, int fd, bool temp) : fd(fd), temp(temp) +{ + std::size_t nsz; + + /* Normalize path */ + this->fname = fname; + rspamd_normalize_path_inplace(this->fname.data(), this->fname.size(), &nsz); + this->fname.resize(nsz); +} + raii_locked_file::~raii_locked_file() noexcept { diff --git a/src/libutil/cxx/file_util.hxx b/src/libutil/cxx/file_util.hxx index 097ce03a7..9fbcda540 100644 --- a/src/libutil/cxx/file_util.hxx +++ b/src/libutil/cxx/file_util.hxx @@ -126,7 +126,7 @@ protected: std::string fname; struct stat st; - explicit raii_file(const char *fname, int fd, bool temp) : fd(fd), temp(temp), fname(fname) {} + explicit raii_file(const char *fname, int fd, bool temp); }; /** * A simple RAII object to contain a file descriptor with an flock wrap