Skip to content

Commit

Permalink
Added check for maximum size of downloaded file names (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedieaston authored Jan 12, 2022
1 parent cfd8b29 commit 7481c14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/AppInstallerCLICore/Workflows/DownloadFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -76,7 +77,7 @@ namespace AppInstaller::CLI::Workflow
filename = Utility::ConvertToUTF16(manifest.Id + '.' + manifest.Version);
}

filename += GetInstallerFileExtension(context);
filename += installerExtension;

return filename;
}
Expand Down

0 comments on commit 7481c14

Please sign in to comment.