aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-03-02 09:46:05 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-03-02 09:46:05 +0000
commit54451443604913b8239e2819147b0cb73817a860 (patch)
treec43e9c250b49abe6440e4698b89ba3564b2a018a /src
parentadb5461ebba1fe237d85e1233bc0da9e78925a1e (diff)
downloadrspamd-54451443604913b8239e2819147b0cb73817a860.tar.gz
rspamd-54451443604913b8239e2819147b0cb73817a860.zip
[Fix] Normalize glob paths to avoid hash table misses
Diffstat (limited to 'src')
-rw-r--r--src/libserver/hyperscan_tools.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libserver/hyperscan_tools.cxx b/src/libserver/hyperscan_tools.cxx
index 296d27335..1953e9b32 100644
--- a/src/libserver/hyperscan_tools.cxx
+++ b/src/libserver/hyperscan_tools.cxx
@@ -229,23 +229,27 @@ public:
if (glob(glob_pattern.c_str(), 0, nullptr, &globbuf) == 0) {
for (auto i = 0; i < globbuf.gl_pathc; i++) {
- const auto *path = globbuf.gl_pathv[i];
+ auto path = std::string{globbuf.gl_pathv[i]};
+ std::size_t nsz;
struct stat st;
- if (stat(path, &st) == -1) {
+ rspamd_normalize_path_inplace(path.data(), path.size(), &nsz);
+ path.resize(nsz);
+
+ if (stat(path.c_str(), &st) == -1) {
msg_debug_hyperscan_lambda("cannot stat file %s: %s",
- path, strerror(errno));
+ path.c_str(), strerror(errno));
continue;
}
if (S_ISREG(st.st_mode)) {
if (!known_cached_files.contains(path)) {
- msg_info_hyperscan_lambda("remove stale hyperscan file %s", path);
- unlink(path);
+ msg_info_hyperscan_lambda("remove stale hyperscan file %s", path.c_str());
+ unlink(path.c_str());
}
else {
msg_debug_hyperscan_lambda("found known hyperscan file %s, size: %Hz",
- path, st.st_size);
+ path.c_str(), st.st_size);
}
}
}