From dbd15cf7048d3705b86f59d7f48b49278f4c2582 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 18 May 2022 00:35:02 +0300 Subject: [PATCH] mu-maildir: don't allow empty path for new maildir be a bit stricter. --- lib/mu-maildir.cc | 11 +++++++---- lib/mu-maildir.hh | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/mu-maildir.cc b/lib/mu-maildir.cc index 0a7d2d77..b65573ec 100644 --- a/lib/mu-maildir.cc +++ b/lib/mu-maildir.cc @@ -67,6 +67,9 @@ slowpath: static Mu::Result create_maildir(const std::string& path, mode_t mode) { + if (path.empty()) + return Err(Error{Error::Code::File, "path must not be empty"}); + std::array subdirs = {"new", "cur", "tmp"}; for (auto&& subdir: subdirs) { @@ -523,10 +526,10 @@ determine_dst_filename(const std::string& file, Flags flags, * sanity checks */ static Mu::Result -check_determine_target_params (const std::string& old_path, - const std::string& root_maildir_path, - const std::string& target_maildir, - Flags newflags) +check_determine_target_params (const std::string& old_path, + const std::string& root_maildir_path, + const std::string& target_maildir, + Flags newflags) { if (!g_path_is_absolute(old_path.c_str())) return Err(Error{Error::Code::File, diff --git a/lib/mu-maildir.hh b/lib/mu-maildir.hh index 06c5f60c..f36f70c6 100644 --- a/lib/mu-maildir.hh +++ b/lib/mu-maildir.hh @@ -39,7 +39,8 @@ namespace Mu { * *not* try to remove the parts the were created. it *will* create any parent * dirs that are not yet existent. * - * @param path the path (missing components will be created, as in 'mkdir -p') + * @param path the path (missing components will be created, as in 'mkdir -p'). + * must be non-empty * @param mode the file mode (e.g., 0755) * @param noindex add a .noindex file to the maildir, so it will be excluded * from indexing by 'mu index'