winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7481c148ac71e822d2a211c6055070b36275b38a
parent cfd8b296f3339f6ef6b714af8d4f9959a78fc9c1
Author: Easton Pillay <easton@planeteaston.com>
Date:   Wed, 12 Jan 2022 15:54:12 -0600

Added check for maximum size of downloaded file names (#1842)


Diffstat:
Msrc/AppInstallerCLICore/Workflows/DownloadFlow.cpp | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp b/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp @@ -63,10 +63,11 @@ namespace AppInstaller::CLI::Workflow { // Get file name from download URI std::filesystem::path filename = GetFileNameFromURI(context.Get<Execution::Data::Installer>()->Url); + std::wstring_view installerExtension = GetInstallerFileExtension(context); - // Assuming that we find a stem value in the URI, use it. + // Assuming that we find a safe stem value in the URI, use it. // This should be extremely common, but just in case fall back to the older name style. - if (filename.has_stem()) + if (filename.has_stem() && ((filename.string().size() + installerExtension.size()) < MAX_PATH)) { filename = filename.stem(); } @@ -76,7 +77,7 @@ namespace AppInstaller::CLI::Workflow filename = Utility::ConvertToUTF16(manifest.Id + '.' + manifest.Version); } - filename += GetInstallerFileExtension(context); + filename += installerExtension; return filename; }