From dc610f9ce3e3526e4c9e52337d33b2caec632daf Mon Sep 17 00:00:00 2001 From: Acts1631 Date: Thu, 27 Aug 2026 12:52:49 -0400 Subject: [PATCH] db/update: limit archive entry path length Archive entries can exceed filesystem path limits. Deep paths make UpdateArchiveTree() allocate a virtual Directory for each component, allowing a small ZIP file to consume hundreds of megabytes during a database update. Ignore paths that cannot fit within MPD_PATH_MAX. --- src/db/update/Archive.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/db/update/Archive.cxx b/src/db/update/Archive.cxx index 2f14f6071b..f789ae8463 100644 --- a/src/db/update/Archive.cxx +++ b/src/db/update/Archive.cxx @@ -10,6 +10,7 @@ #include "protocol/Verify.hxx" #include "lib/fmt/PathFormatter.hxx" #include "fs/AllocatedPath.hxx" +#include "fs/Limits.hxx" #include "storage/FileInfo.hxx" #include "archive/ArchiveList.hxx" #include "archive/ArchivePlugin.hxx" @@ -40,6 +41,9 @@ void UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory, std::string_view name) noexcept { + if (name.size() >= MPD_PATH_MAX) + return; + const auto [child_name, rest] = Split(name, '/'); if (rest.data() != nullptr) { if (!VerifyRelativePathUTF8(child_name))