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.
This commit is contained in:
Dirk-Jan C. Binnema 2023-07-18 23:16:42 +03:00
parent f3c303106d
commit 885903c496
1 changed files with 9 additions and 0 deletions

View File

@ -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