]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] A workaround for brain-damaged std::filesystem behaviour
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 27 Oct 2023 07:12:16 +0000 (08:12 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 27 Oct 2023 07:12:16 +0000 (08:12 +0100)
Issue: #4665

src/libserver/hyperscan_tools.cxx

index dc0586107306a9d4de502a0f2388aa27b8af1efa..f7bd78a9b684e6fb03e35254cab35b368707ef5c 100644 (file)
@@ -147,22 +147,11 @@ public:
 
                fpath = std::filesystem::canonical(fpath, ec);
 
-               if (!ec) {
+               if (!ec && ec.value() != 0) {
                        msg_err_hyperscan("invalid path: \"%s\", error message: %s", fname, ec.message().c_str());
                        return;
                }
 
-               if (fpath.empty()) {
-                       msg_err_hyperscan("attempt to add an empty hyperscan file!");
-                       return;
-               }
-
-               if (!std::filesystem::exists(fpath)) {
-                       msg_err_hyperscan("attempt to add non existing hyperscan file: %s, %s", fpath.c_str(),
-                                                         strerror(errno));
-                       return;
-               }
-
                auto dir = fpath.parent_path();
                auto ext = fpath.extension();
 
@@ -188,7 +177,7 @@ public:
 
                fpath = std::filesystem::canonical(fpath, ec);
 
-               if (!ec) {
+               if (!ec && ec.value() != 0) {
                        msg_err_hyperscan("invalid path to remove: \"%s\", error message: %s",
                                                          fname, ec.message().c_str());
                        return;