commit 8d70c4a: [Fix] A workaround for brain-damaged std::filesystem behaviour

Vsevolod Stakhov vsevolod at rspamd.com
Fri Oct 27 07:14:03 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-10-27 08:12:16 +0100
URL: https://github.com/rspamd/rspamd/commit/8d70c4a50198b18f2e16ab9ff58ca43df0d4ebd8 (HEAD -> master)

[Fix] A workaround for brain-damaged std::filesystem behaviour
Issue: #4665

---
 src/libserver/hyperscan_tools.cxx | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

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;


More information about the Commits mailing list