Skip to content

Commit

Permalink
Fix potential crash in public folder retrieval, and construct path ou…
Browse files Browse the repository at this point in the history
…rself for now (#96)
  • Loading branch information
JohnMcPMS authored Apr 30, 2020
1 parent 9858113 commit 3929ecd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/AppInstallerCommonCore/ExtensionCatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once
#include "pch.h"
#include "winget/ExtensionCatalog.h"
#include "AppInstallerErrors.h"
#include "AppInstallerLogging.h"
#include "AppInstallerStrings.h"

Expand All @@ -19,7 +20,9 @@ namespace AppInstaller::Deployment

std::filesystem::path Extension::GetPublicFolderPath() const
{
return m_extension.GetPublicFolderAsync().get().Path().c_str();
auto folder = m_extension.GetPublicFolderAsync().get();
THROW_HR_IF(APPINSTALLER_CLI_ERROR_EXTENSION_PUBLIC_FAILED, !folder);
return folder.Path().c_str();
}

winrt::Windows::ApplicationModel::PackageVersion Extension::GetPackageVersion() const
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCommonCore/Public/AppInstallerErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define APPINSTALLER_CLI_ERROR_NO_SOURCES_DEFINED ((HRESULT)0x8A150015)
#define APPINSTALLER_CLI_ERROR_MULTIPLE_APPLICATIONS_FOUND ((HRESULT)0x8A150016)
#define APPINSTALLER_CLI_ERROR_NO_MANIFEST_FOUND ((HRESULT)0x8A150017)
#define APPINSTALLER_CLI_ERROR_EXTENSION_PUBLIC_FAILED ((HRESULT)0x8A150018)

namespace AppInstaller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ namespace AppInstaller::Repository::Microsoft
THROW_HR(APPINSTALLER_CLI_ERROR_SOURCE_DATA_MISSING);
}

std::filesystem::path indexLocation = extension->GetPublicFolderPath();
indexLocation /= s_PreIndexedPackageSourceFactory_IndexFileName;
// To work around an issue with accessing the public folder, we are temporarily
// constructing the location ourself. This was already the case for the non-packaged
// runtime, and we can fix both in the future. The only problem with this is that
// the directory in the extension *must* be Public, rather than one set by the creator.
std::filesystem::path indexLocation = extension->GetPackagePath();
indexLocation /= s_PreIndexedPackageSourceFactory_IndexFilePath;

SQLiteIndex index = SQLiteIndex::Open(indexLocation.u8string(), SQLiteIndex::OpenDisposition::Immutable);

Expand Down

0 comments on commit 3929ecd

Please sign in to comment.