Skip to content

Commit cb3d70f

Browse files
authored
Merge pull request #104395 from dotnet/merge/release/8.0-to-release/8.0-staging
[automated] Merge branch 'release/8.0' => 'release/8.0-staging'
2 parents 79ebd43 + 62cc752 commit cb3d70f

File tree

28 files changed

+774
-124
lines changed

28 files changed

+774
-124
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Inter-branch merge workflow
2+
on:
3+
push:
4+
branches:
5+
- release/**
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
Merge:
13+
uses: dotnet/arcade/.github/workflows/inter-branch-merge-base.yml@main

eng/Versions.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@
136136
<SystemSecurityCryptographyOpenSslVersion>5.0.0</SystemSecurityCryptographyOpenSslVersion>
137137
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
138138
<SystemSecurityPermissionsVersion>7.0.0</SystemSecurityPermissionsVersion>
139+
<!-- The JSON version that's present in minimum MSBuild / VS version that this release is supported on -->
140+
<SystemTextJsonToolsetVersion>7.0.3</SystemTextJsonToolsetVersion>
139141
<SystemTextJsonVersion>8.0.0-rc.1.23406.6</SystemTextJsonVersion>
140142
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
141143
<SystemThreadingAccessControlVersion>7.0.0</SystemThreadingAccessControlVersion>

src/coreclr/debug/createdump/createdump.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ extern MINIDUMP_TYPE GetMiniDumpType(DumpType dumpType);
151151

152152
#ifdef HOST_WINDOWS
153153
extern std::string GetLastErrorString();
154+
extern DWORD GetTempPathWrapper(IN DWORD nBufferLength, OUT LPSTR lpBuffer);
155+
#else
156+
#define GetTempPathWrapper GetTempPathA
154157
#endif
155158
extern void printf_status(const char* format, ...);
156159
extern void printf_error(const char* format, ...);

src/coreclr/debug/createdump/createdumpmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int createdump_main(const int argc, const char* argv[])
205205
ArrayHolder<char> tmpPath = new char[MAX_LONGPATH];
206206
if (options.DumpPathTemplate == nullptr)
207207
{
208-
if (::GetTempPathA(MAX_LONGPATH, tmpPath) == 0)
208+
if (GetTempPathWrapper(MAX_LONGPATH, tmpPath) == 0)
209209
{
210210
printf_error("GetTempPath failed\n");
211211
return -1;

src/coreclr/debug/createdump/createdumpwindows.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,38 @@ GetLastErrorString()
135135
return result;
136136
}
137137

138+
139+
typedef DWORD(WINAPI *pfnGetTempPathA)(DWORD nBufferLength, LPSTR lpBuffer);
140+
141+
static volatile pfnGetTempPathA
142+
g_pfnGetTempPathA = nullptr;
143+
144+
145+
DWORD
146+
GetTempPathWrapper(
147+
IN DWORD nBufferLength,
148+
OUT LPSTR lpBuffer)
149+
{
150+
if (g_pfnGetTempPathA == nullptr)
151+
{
152+
HMODULE hKernel32 = LoadLibraryExW(L"kernel32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
153+
154+
pfnGetTempPathA pLocalGetTempPathA = NULL;
155+
if (hKernel32 != NULL)
156+
{
157+
// store to thread local variable to prevent data race
158+
pLocalGetTempPathA = (pfnGetTempPathA)::GetProcAddress(hKernel32, "GetTempPath2A");
159+
}
160+
161+
if (pLocalGetTempPathA == NULL) // method is only available with Windows 10 Creators Update or later
162+
{
163+
g_pfnGetTempPathA = &GetTempPathA;
164+
}
165+
else
166+
{
167+
g_pfnGetTempPathA = pLocalGetTempPathA;
168+
}
169+
}
170+
171+
return g_pfnGetTempPathA(nBufferLength, lpBuffer);
172+
}

src/coreclr/inc/longfilepathwrappers.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ SearchPathWrapper(
5959
_Out_opt_ LPWSTR * lpFilePart
6060
);
6161

62-
DWORD WINAPI GetTempPathWrapper(
63-
SString& lpBuffer
64-
);
65-
6662
DWORD
6763
GetModuleFileNameWrapper(
6864
_In_opt_ HMODULE hModule,

src/coreclr/inc/winwrap.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@
204204
//Can not use extended syntax
205205
#define WszGetFullPathName GetFullPathNameW
206206

207-
//Long Files will not work on these till redstone
208-
#define WszGetTempPath GetTempPathWrapper
209-
210207
//APIS which have a buffer as an out parameter
211208
#define WszGetEnvironmentVariable GetEnvironmentVariableWrapper
212209
#define WszSearchPath SearchPathWrapper

src/coreclr/utilcode/longfilepathwrappers.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -184,47 +184,6 @@ GetModuleFileNameWrapper(
184184
return ret;
185185
}
186186

187-
DWORD WINAPI GetTempPathWrapper(
188-
SString& lpBuffer
189-
)
190-
{
191-
CONTRACTL
192-
{
193-
NOTHROW;
194-
}
195-
CONTRACTL_END;
196-
197-
HRESULT hr = S_OK;
198-
DWORD ret = 0;
199-
DWORD lastError = 0;
200-
201-
EX_TRY
202-
{
203-
//Change the behaviour in Redstone to retry
204-
COUNT_T size = MAX_LONGPATH;
205-
206-
ret = GetTempPathW(
207-
size,
208-
lpBuffer.OpenUnicodeBuffer(size - 1)
209-
);
210-
211-
lastError = GetLastError();
212-
lpBuffer.CloseBuffer(ret);
213-
}
214-
EX_CATCH_HRESULT(hr);
215-
216-
if (hr != S_OK)
217-
{
218-
SetLastError(hr);
219-
}
220-
else if (ret == 0)
221-
{
222-
SetLastError(lastError);
223-
}
224-
225-
return ret;
226-
}
227-
228187
DWORD WINAPI GetEnvironmentVariableWrapper(
229188
_In_opt_ LPCTSTR lpName,
230189
_Out_opt_ SString& lpBuffer

src/installer/managed/Microsoft.NET.HostModel/Microsoft.NET.HostModel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ItemGroup>
2323
<!-- we need to keep the version of System.Reflection.Metadata in sync with dotnet/msbuild and dotnet/sdk -->
2424
<PackageReference Include="System.Reflection.Metadata" Version="6.0.0" />
25-
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonVersion)" />
25+
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonToolsetVersion)" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ internal static void ReadDsaPrivateKey(
2525
throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
2626
}
2727

28-
DssParms parms = DssParms.Decode(algId.Parameters.Value, AsnEncodingRules.BER);
29-
30-
ret = new DSAParameters
31-
{
32-
P = parms.P.ToByteArray(isUnsigned: true, isBigEndian: true),
33-
Q = parms.Q.ToByteArray(isUnsigned: true, isBigEndian: true),
34-
};
35-
36-
ret.G = parms.G.ExportKeyParameter(ret.P.Length);
37-
3828
BigInteger x;
3929

4030
try
@@ -57,6 +47,34 @@ internal static void ReadDsaPrivateKey(
5747
throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding, e);
5848
}
5949

50+
DssParms parms = DssParms.Decode(algId.Parameters.Value, AsnEncodingRules.BER);
51+
52+
// Sanity checks from FIPS 186-4 4.1/4.2. Since FIPS 186-5 withdrew DSA/DSS
53+
// these will never change again.
54+
//
55+
// This technically allows a non-standard combination of 1024-bit P and 256-bit Q,
56+
// but that will get filtered out by the underlying provider.
57+
// These checks just prevent obviously bad data from wasting work on reinterpretation.
58+
59+
if (parms.P.Sign < 0 ||
60+
parms.Q.Sign < 0 ||
61+
!IsValidPLength(parms.P.GetBitLength()) ||
62+
!IsValidQLength(parms.Q.GetBitLength()) ||
63+
parms.G <= 1 ||
64+
parms.G >= parms.P ||
65+
x <= 1 ||
66+
x >= parms.Q)
67+
{
68+
throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
69+
}
70+
71+
ret = new DSAParameters
72+
{
73+
P = parms.P.ToByteArray(isUnsigned: true, isBigEndian: true),
74+
Q = parms.Q.ToByteArray(isUnsigned: true, isBigEndian: true),
75+
};
76+
77+
ret.G = parms.G.ExportKeyParameter(ret.P.Length);
6078
ret.X = x.ExportKeyParameter(ret.Q.Length);
6179

6280
// The public key is not contained within the format, calculate it.
@@ -69,6 +87,11 @@ internal static void ReadDsaPublicKey(
6987
in AlgorithmIdentifierAsn algId,
7088
out DSAParameters ret)
7189
{
90+
if (!algId.Parameters.HasValue)
91+
{
92+
throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
93+
}
94+
7295
BigInteger y;
7396

7497
try
@@ -88,13 +111,27 @@ internal static void ReadDsaPublicKey(
88111
throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding, e);
89112
}
90113

91-
if (!algId.Parameters.HasValue)
114+
DssParms parms = DssParms.Decode(algId.Parameters.Value, AsnEncodingRules.BER);
115+
116+
// Sanity checks from FIPS 186-4 4.1/4.2. Since FIPS 186-5 withdrew DSA/DSS
117+
// these will never change again.
118+
//
119+
// This technically allows a non-standard combination of 1024-bit P and 256-bit Q,
120+
// but that will get filtered out by the underlying provider.
121+
// These checks just prevent obviously bad data from wasting work on reinterpretation.
122+
123+
if (parms.P.Sign < 0 ||
124+
parms.Q.Sign < 0 ||
125+
!IsValidPLength(parms.P.GetBitLength()) ||
126+
!IsValidQLength(parms.Q.GetBitLength()) ||
127+
parms.G <= 1 ||
128+
parms.G >= parms.P ||
129+
y <= 1 ||
130+
y >= parms.P)
92131
{
93132
throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding);
94133
}
95134

96-
DssParms parms = DssParms.Decode(algId.Parameters.Value, AsnEncodingRules.BER);
97-
98135
ret = new DSAParameters
99136
{
100137
P = parms.P.ToByteArray(isUnsigned: true, isBigEndian: true),
@@ -105,6 +142,25 @@ internal static void ReadDsaPublicKey(
105142
ret.Y = y.ExportKeyParameter(ret.P.Length);
106143
}
107144

145+
private static bool IsValidPLength(long pBitLength)
146+
{
147+
return pBitLength switch
148+
{
149+
// FIPS 186-3/186-4
150+
1024 or 2048 or 3072 => true,
151+
// FIPS 186-1/186-2
152+
>= 512 and < 1024 => pBitLength % 64 == 0,
153+
_ => false,
154+
};
155+
}
156+
157+
private static bool IsValidQLength(long qBitLength)
158+
{
159+
// FIPS 186-1/186-2 only allows 160
160+
// FIPS 186-3/186-4 allow 160/224/256
161+
return qBitLength is 160 or 224 or 256;
162+
}
163+
108164
internal static void ReadSubjectPublicKeyInfo(
109165
ReadOnlySpan<byte> source,
110166
out int bytesRead,

0 commit comments

Comments
 (0)