Skip to content

Commit 2cfa780

Browse files
authored
Merge pull request #418 from microsoft/dev/willxie/r2m
Merge release to main; Version bump to 1.0.43
2 parents 43c4e97 + 8660a9d commit 2cfa780

File tree

26 files changed

+160
-113
lines changed

26 files changed

+160
-113
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ Please format the changes as follows:
77
+ BugFixes:
88
+ Updates:
99

10+
## 1.0.43
11+
12+
## 1.0.42
13+
+ BugFixes:
14+
+ Fix Linux build
15+
1016
## 1.0.41
17+
+ Updates:
18+
+ Remove PathCch functions in order to support Win7
1119

1220
## 1.0.40
1321
+ No new changes.

build/Version.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
-->
1313
<SemanticVersionMajor>1</SemanticVersionMajor>
1414
<SemanticVersionMinor>0</SemanticVersionMinor>
15-
<SemanticVersionPatch>41</SemanticVersionPatch>
15+
<SemanticVersionPatch>43</SemanticVersionPatch>
1616

1717
<FileVersionMajor>15</FileVersionMajor>
1818
<FileVersionMinor>1</FileVersionMinor>
@@ -30,15 +30,15 @@
3030
-->
3131
<ProxyFileVersionMajor>$(SemanticVersionMajor)</ProxyFileVersionMajor>
3232
<ProxyFileVersionMinor>0</ProxyFileVersionMinor>
33-
<ProxyFileVersionPatch>2</ProxyFileVersionPatch>
33+
<ProxyFileVersionPatch>3</ProxyFileVersionPatch>
3434
<ProxyFileVersion>$(ProxyFileVersionMajor).$(ProxyFileVersionMinor).$(ProxyFileVersionPatch)</ProxyFileVersion>
3535

3636
<!--
3737
Date when Semantic Version was changed.
3838
Update for every public release.
3939
Format is YYYY-MM-DD
4040
-->
41-
<SemanticVersionDate>2021-05-05</SemanticVersionDate>
41+
<SemanticVersionDate>2021-08-03</SemanticVersionDate>
4242

4343
<!--
4444
Build version is used to distinguish internally built NuGet packages.

build/yaml/jobs/codeanalysis/apiscan.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
# No dependencies. Requires Build Stages to ensure that binaries are built
1414

1515
pool:
16-
name: VSEng-ReleasePool
16+
name: VSEngSS-MicroBuild2019
1717
demands:
1818
- msbuild
1919
- visualstudio
@@ -25,13 +25,20 @@ jobs:
2525
- checkout: self
2626
clean: true
2727

28+
# Expire ApiScan one day before declared expirary, to make sure that we update it before
29+
# it expires, regardless of timezone
30+
- powershell: if ((Get-Date).Add((New-TimeSpan -Days 1)) -ge (Get-Date -Date "$(ApiScanExpiration)")) { throw "ApiScan key expired. Please update" }
31+
2832
- task: DownloadBuildArtifacts@0
2933
displayName: Download Windows Files (Release)
3034
inputs:
3135
downloadType: single
3236
artifactName: binaries-windows-Release
3337
downloadPath: $(Build.ArtifactStagingDirectory)
3438

39+
- task: NodeTool@0
40+
displayName: 'Use Node 6.x'
41+
3542
# Scan only native files that are released as part of the product.
3643
- task: CopyFiles@2
3744
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)\ApiScan'
@@ -58,6 +65,8 @@ jobs:
5865
symbolsFolder: 'SRV*http://symweb;$(Build.ArtifactStagingDirectory)/ApiScan'
5966
isLargeApp: false
6067
continueOnError: true
68+
env:
69+
AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(TenantId);AppKey=$(AppKey)
6170

6271
# Publish SecurityAnalysis Logs
6372
- template: ../../steps/codeanalysis/publishreports.yaml

build/yaml/pipelines/codeanalysis.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
name: $(date:yyyyMMdd)$(rev:rr)
1010

1111
variables:
12-
TeamName: ClrInstrumentationEngine
12+
- group: CLRIE-ApiScan
13+
- name: TeamName
14+
value: ClrInstrumentationEngine
15+
readonly: true
1316

1417
stages:
1518

build/yaml/steps/microbuild/signing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
displayName: Set Signing From Parameters
1515
1616
# nuget install MicroBuild.Plugins.Signing
17-
- task: MicroBuildSigningPlugin@2
17+
- task: MicroBuildSigningPlugin@3
1818
displayName: Install Signing Plugin
1919
condition: and(succeeded(), in(variables['SignType'], 'Real', 'Test'))
2020
inputs:

src/Common.Headers/Common.Headers.vcxitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<ClInclude Include="$(MSBuildThisFileDirectory)InitOnce.h" />
2020
<ClInclude Include="$(MSBuildThisFileDirectory)SafeFindFileHandle.h" />
2121
<ClInclude Include="$(MSBuildThisFileDirectory)Singleton.h" />
22+
<ClInclude Include="$(MSBuildThisFileDirectory)StringUtils.h" />
2223
<ClInclude Include="$(MSBuildThisFileDirectory)tstring.h" />
2324
</ItemGroup>
2425
</Project>

src/Common.Headers/StringUtils.h

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#pragma once
5+
6+
#include <string>
7+
8+
class StringUtils
9+
{
10+
public:
11+
12+
// The maximum string length. Set arbitrarily;
13+
static const size_t MAX_STRING_LEN = 10000;
14+
15+
// Gets the length of the given string using the the standard wcsnlen_s.
16+
// Returns E_BOUNDS if the length of wszString is greater than MAX_STRING_LEN.
17+
// For use with untrusted data which may not have a null terminator.
18+
static HRESULT WStringLen(_In_ const WCHAR* wszString, _Out_ size_t& len)
19+
{
20+
len = wcsnlen_s(wszString, MAX_STRING_LEN);
21+
22+
if (len >= MAX_STRING_LEN)
23+
{
24+
return E_BOUNDS;
25+
}
26+
27+
return S_OK;
28+
}
29+
30+
// Gets the length of the given string using the standard strnlen.
31+
// Returns E_BOUNDS if the length of wszString is greater than MAX_STRING_LEN.
32+
// For use with untrusted data which may not have a null terminator.
33+
static HRESULT StringLen(_In_ const char* szString, _Out_ size_t& len)
34+
{
35+
len = strnlen(szString, MAX_STRING_LEN);
36+
37+
if (len >= MAX_STRING_LEN)
38+
{
39+
return E_BOUNDS;
40+
}
41+
42+
return S_OK;
43+
}
44+
45+
// Gets the length of the given string using the standard wcsnlen_s.
46+
// Yields the same result as calling wcsnlen_s(wszString, MAX_STRING_LEN);
47+
// For use with untrusted data which may not have a null terminator.
48+
static size_t WStringLen(_In_ const WCHAR* wszString)
49+
{
50+
return wcsnlen_s(wszString, MAX_STRING_LEN);
51+
}
52+
53+
54+
// Gets the length of the given string using the standard strnlen.
55+
// Yields the same result as calling strnlen(szString, MAX_STRING_LEN);
56+
// For use with untrusted data which may not have a null terminator.
57+
static size_t StringLen(_In_ const char* szString)
58+
{
59+
return strnlen(szString, MAX_STRING_LEN);
60+
}
61+
62+
// Modifies pwszPath by appending pwszMore.
63+
// Checks cBounds before appending to prevent buffer overflows.
64+
//
65+
// This function wraps PathAppend since supporting Win7 means PathCchAppend is not available.
66+
static HRESULT SafePathAppend(_Inout_updates_z_(cBounds) LPWSTR pwszPath, _In_ LPCWSTR pwszMore, _In_ size_t cBounds)
67+
{
68+
#ifndef PLATFORM_UNIX
69+
// If PathAppend fails, the destination buffer will be cleared. Check bounds before appending.
70+
// +1 for additional directory separator character, +1 for null terminator.
71+
if (StringUtils::WStringLen(pwszPath) + StringUtils::WStringLen(pwszMore) + 2 > cBounds)
72+
{
73+
return E_BOUNDS;
74+
}
75+
76+
if (!PathAppend(pwszPath, pwszMore))
77+
{
78+
return E_FAIL;
79+
}
80+
81+
return S_OK;
82+
#else
83+
return PathCchAppend(pwszPath, MAX_PATH, pwszMore);
84+
#endif
85+
}
86+
};

src/Common.Lib/Common.Lib.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<SubSystem>Windows</SubSystem>
4848
<GenerateDebugInformation>true</GenerateDebugInformation>
4949
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
50-
<AdditionalDependencies>Common.Lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;msxml6.lib;version.lib;mscoree.lib;%(AdditionalDependencies);Faultrep.lib;PathCch.lib</AdditionalDependencies>
50+
<AdditionalDependencies>Common.Lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;msxml6.lib;version.lib;mscoree.lib;Faultrep.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
5151
<AdditionalOptions Condition="'$(Platform)'=='Win32'">/SafeSEH %(AdditionalOptions)</AdditionalOptions>
5252
</Link>
5353
<Lib>

src/InstrumentationEngine.Lib/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ set(src_files
2222
./InstrumentationMethodSetting.cpp
2323
./LoggerService.cpp
2424
./Logging.cpp
25-
./StringUtils.cpp
2625
)
2726

2827
add_lib(${PROJECT_NAME}

src/InstrumentationEngine.Lib/InstrumentationEngine.Lib.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
<ClInclude Include="SharedArray.h" />
115115
<ClInclude Include="SignatureValidator.h" />
116116
<ClInclude Include="stdafx.h" />
117-
<ClInclude Include="StringUtils.h" />
118117
<ClInclude Include="targetver.h" />
119118
<ClInclude Include="Util.h" />
120119
</ItemGroup>
@@ -138,7 +137,6 @@
138137
<ClCompile Include="stdafx.cpp">
139138
<PrecompiledHeader>Create</PrecompiledHeader>
140139
</ClCompile>
141-
<ClCompile Include="StringUtils.cpp" />
142140
</ItemGroup>
143141
<ItemGroup>
144142
<ProjectReference Include="..\Common.Lib\Common.Lib.vcxproj">

src/InstrumentationEngine.Lib/InstrumentationMethod.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef PLATFORM_UNIX
99
#include "SignatureValidator.h"
1010
#endif
11+
#include "../Common.Headers/StringUtils.h"
1112

1213

1314
MicrosoftInstrumentationEngine::CInstrumentationMethod::CInstrumentationMethod(
@@ -80,10 +81,24 @@ HRESULT MicrosoftInstrumentationEngine::CInstrumentationMethod::InitializeCore(
8081
return E_INVALIDARG;
8182
}
8283

84+
if ((m_bstrModuleFolder.Length() >= MAX_PATH))
85+
{
86+
CLogging::LogError(_T("CInstrumentationMethod::Initialize - module folder path is too long, PID: %u"), GetCurrentProcessId());
87+
return E_BOUNDS;
88+
}
89+
8390
WCHAR wszModuleFullPath[MAX_PATH];
84-
memset(wszModuleFullPath, 0, MAX_PATH);
91+
ZeroMemory(wszModuleFullPath, MAX_PATH * sizeof(WCHAR));
8592
wcscpy_s(wszModuleFullPath, MAX_PATH, m_bstrModuleFolder);
86-
PathCchAppend(wszModuleFullPath, MAX_PATH, m_bstrModule);
93+
94+
hr = StringUtils::SafePathAppend(wszModuleFullPath, m_bstrModule, MAX_PATH);
95+
if (FAILED(hr))
96+
{
97+
CLogging::LogError(
98+
_T("CInstrumentationMethod::Initialize - failed to append method dll to method configuration folder, PID: %u, hr: %x, target: '%s' + '%s'"),
99+
GetCurrentProcessId(), hr, m_bstrModuleFolder.m_str, m_bstrModule.m_str);
100+
return hr;
101+
}
87102

88103
m_hmod = ::LoadLibrary(wszModuleFullPath);
89104

src/InstrumentationEngine.Lib/StringUtils.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/InstrumentationEngine.Lib/StringUtils.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/InstrumentationEngine.Lib/stdafx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using namespace ATL;
4747
#include <sal.h>
4848

4949
#ifndef PLATFORM_UNIX
50-
#include <PathCch.h>
50+
#include <Shlwapi.h>
5151
#endif
5252

5353
#ifdef PLATFORM_UNIX

src/InstrumentationEngine.ProfilerProxy.Lib/InstrumentationEngine.ProfilerProxy.Lib.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<SubSystem>Windows</SubSystem>
4848
<GenerateDebugInformation>true</GenerateDebugInformation>
4949
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
50-
<AdditionalDependencies>Common.Lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;msxml6.lib;version.lib;mscoree.lib;%(AdditionalDependencies);Faultrep.lib;PathCch.lib</AdditionalDependencies>
50+
<AdditionalDependencies>Common.Lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;msxml6.lib;version.lib;mscoree.lib;Faultrep.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
5151
<AdditionalOptions Condition="'$(Platform)'=='Win32'">/SafeSEH %(AdditionalOptions)</AdditionalOptions>
5252
</Link>
5353
<Lib>

src/InstrumentationEngine.ProfilerProxy/InstrumentationEngine.ProfilerProxy.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
</ImportGroup>
6666
<ItemDefinitionGroup>
6767
<ClCompile>
68-
<AdditionalIncludeDirectories>$(OutDir);..\Common.Lib;..\InstrumentationEngine.ProfilerProxy.Lib;..\..\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
68+
<AdditionalIncludeDirectories>$(OutDir);..\Common.Lib;..\InstrumentationEngine.ProfilerProxy.Lib;..\..\inc;..\InstrumentationEngine.Lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6969
<WarningLevel>Level3</WarningLevel>
7070
<PreprocessorDefinitions>_WINDOWS;_USRDLL;INSTRUMENTATIONENGINEPROFILERPROXY_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
7171
<PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -74,7 +74,7 @@
7474
<SubSystem>Windows</SubSystem>
7575
<GenerateDebugInformation>true</GenerateDebugInformation>
7676
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
77-
<AdditionalDependencies>Common.Lib.lib;InstrumentationEngine.ProfilerProxy.Lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;msxml6.lib;version.lib;mscoree.lib;%(AdditionalDependencies);Faultrep.lib;PathCch.lib</AdditionalDependencies>
77+
<AdditionalDependencies>Common.Lib.lib;InstrumentationEngine.ProfilerProxy.Lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;msxml6.lib;version.lib;mscoree.lib;Faultrep.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
7878
<AdditionalOptions Condition="'$(Platform)'=='Win32'">/SafeSEH %(AdditionalOptions)</AdditionalOptions>
7979
</Link>
8080
</ItemDefinitionGroup>

0 commit comments

Comments
 (0)