Skip to content

Commit

Permalink
Turn space-separated string into array
Browse files Browse the repository at this point in the history
  • Loading branch information
mherrmann committed Jul 28, 2021
1 parent 497b5a7 commit bb826fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
9 changes: 6 additions & 3 deletions omaha/base/constants.h
Expand Up @@ -286,9 +286,12 @@ const TCHAR* const kRegValueVerifyPayloadAuthenticodeSignature =

// If VerifyPayloadAuthenticodeSignature is non-zero in registry (see above),
// then update binaries with the following extensions are Authenticode-verified:
const TCHAR* const kAuthenticodeSignedExtensions =
_T("exe msi dll sys cab ocx xpi xap cat jar ps1 psm1 psd1 ps1xml psc1 acm ")
_T("ax cpl drv efi mui scr sys tsp");
const TCHAR* const kAuthenticodeSignedExtensions[] = {
_T("exe"), _T("msi"), _T("dll"), _T("sys"), _T("cab"), _T("ocx"),
_T("xpi"), _T("xap"), _T("cat"), _T("jar"), _T("ps1"), _T("psm1"),
_T("psd1"), _T("ps1xml"), _T("psc1"), _T("acm "), _T("ax"), _T("cpl"),
_T("drv"), _T("efi"), _T("mui"), _T("scr"), _T("sys"), _T("tsp")
};

#if defined(HAS_DEVICE_MANAGEMENT)
const TCHAR* const kRegValueNameDeviceManagementUrl = _T("DeviceManagementUrl");
Expand Down
11 changes: 5 additions & 6 deletions omaha/goopdate/download_manager.cc
Expand Up @@ -570,12 +570,11 @@ HRESULT DownloadManager::EnsureSignatureIsValid(const CString& file_path) {
ASSERT1(ext);
if (*ext != _T('\0')) {
ext++; // Skip the dot.
CString ext_lower(ext);
ext_lower.MakeLower();
const TCHAR* delim = _T(" ");
CString extensions = delim + CString(kAuthenticodeSignedExtensions) + delim;
if (extensions.Find(delim + ext_lower + delim) != -1) {
return VerifyGoogleAuthenticodeSignature(file_path, true);
for (size_t i = 0; i != arraysize(kAuthenticodeSignedExtensions); ++i) {
CString candidate(kAuthenticodeSignedExtensions[i]);

This comment has been minimized.

Copy link
@sorinj

sorinj Aug 3, 2021

Collaborator

Could inline and do something like CString(kAuthenticodeSignedExtensions[i]).Compare....

This comment has been minimized.

Copy link
@mherrmann

mherrmann Aug 3, 2021

Author Contributor

Resolved in 1648962.

if (candidate.CompareNoCase(ext) == 0) {
return VerifyGoogleAuthenticodeSignature(file_path, true);
}
}
}
return S_OK;
Expand Down
5 changes: 4 additions & 1 deletion omaha/goopdate/download_manager_unittest.cc
Expand Up @@ -1199,9 +1199,12 @@ TEST_F(DownloadManagerUserTest, CachePackage) {

const TCHAR* kFiles[] = {_T("SaveArguments.exe"),
_T("old_google_certificate.dll"),
_T("sha2_0c15be4a15bb0903c901b1d6c265302f.msi")};
_T("sha2_0c15be4a15bb0903c901b1d6c265302f.msi"),
// Ensure unexpected extensions don't crash:
_T("declaration.txt")};
HRESULT kExpected[] = {S_OK,
SIGS_E_INVALID_SIGNATURE,
S_OK,
S_OK};

ASSERT_EQ(arraysize(kFiles), arraysize(kExpected));
Expand Down

0 comments on commit bb826fe

Please sign in to comment.