From: Vsevolod Stakhov Date: Fri, 27 Oct 2023 07:12:16 +0000 (+0100) Subject: [Fix] A workaround for brain-damaged std::filesystem behaviour X-Git-Tag: 3.7.3~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8d70c4a50198b18f2e16ab9ff58ca43df0d4ebd8;p=rspamd.git [Fix] A workaround for brain-damaged std::filesystem behaviour Issue: #4665 --- diff --git a/src/libserver/hyperscan_tools.cxx b/src/libserver/hyperscan_tools.cxx index dc0586107..f7bd78a9b 100644 --- a/src/libserver/hyperscan_tools.cxx +++ b/src/libserver/hyperscan_tools.cxx @@ -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;