From 885903c496d8ad572a3ff919d3c521c5e217bdba Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 18 Jul 2023 23:16:42 +0300 Subject: [PATCH] index: limit length of maildir path to MaxTermLength This limit was already in place, but now we detect it a bit earlier (in the indexer). We _could_ increase it (by using hashes for dirstamps), but right now it's a good catch for circular symlinks. --- lib/index/mu-indexer.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/index/mu-indexer.cc b/lib/index/mu-indexer.cc index 2b56b3f4..1750e4e9 100644 --- a/lib/index/mu-indexer.cc +++ b/lib/index/mu-indexer.cc @@ -141,6 +141,15 @@ Indexer::Private::handler(const std::string& fullpath, struct stat* statbuf, switch (htype) { case Scanner::HandleType::EnterDir: case Scanner::HandleType::EnterNewCur: { + if (fullpath.length() > MaxTermLength) { + // currently the db uses the path as a key, and + // therefore it cannot be too long. We'd get an error + // later anyway but for now it's useful for surviving + // circular symlinks + mu_warning("'{}' is too long; ignore", fullpath); + return false; + } + // in lazy-mode, we ignore this dir if its dirstamp suggest it // is up-to-date (this is _not_ always true; hence we call it // lazy-mode); only for actual message dirs, since the dir