Skip to content

Commit

Permalink
Backport SqlClient 659 to release/3.1: Fix async timeout design leadi…
Browse files Browse the repository at this point in the history
…ng to intermittent wrong data

Backport of dotnet/SqlClient#659 to 3.1

Cherry-picks:
- dotnet/SqlClient@717ceda
- dotnet/SqlClient@2c2f100
- dotnet/SqlClient@81055cf

Resolves CVE-2022-41064.
  • Loading branch information
cheenamalhotra authored and GrabYourPitchforks committed Oct 17, 2022
1 parent f2aa362 commit 1acb337
Show file tree
Hide file tree
Showing 12 changed files with 402 additions and 48 deletions.
13 changes: 8 additions & 5 deletions pkg/Microsoft.Private.PackageBaseline/packageIndex.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,10 @@
"3.1.0",
"3.1.1",
"3.1.2",
"3.1.3"
"3.1.3",
"3.1.4"
],
"BaselineVersion": "3.1.3",
"BaselineVersion": "3.1.4",
"InboxOn": {}
},
"Microsoft.Windows.Compatibility.Shims": {
Expand Down Expand Up @@ -1553,9 +1554,10 @@
"4.8.1",
"4.8.2",
"4.8.3",
"4.8.4"
"4.8.4",
"4.8.5"
],
"BaselineVersion": "4.8.4",
"BaselineVersion": "4.8.5",
"InboxOn": {
"net461": "4.1.0.0",
"monoandroid10": "Any",
Expand All @@ -1580,7 +1582,8 @@
"4.6.1.1": "4.8.1",
"4.6.1.2": "4.8.2",
"4.6.1.3": "4.8.3",
"4.6.1.4": "4.8.4"
"4.6.1.4": "4.8.4",
"4.6.1.5": "4.8.5"
}
},
"System.Data.SqlXml": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<!-- We use the PackageVersion property defined in Packaging.props for the Prerelease packages which are using it to be built -->
<_PreReleasePackageVersion>$(PackageVersion)</_PreReleasePackageVersion>
<PackageVersion>3.1.3</PackageVersion>
<ServiceModelVersion>4.7.1</ServiceModelVersion>
<PackageVersion>3.1.4</PackageVersion>
<ServiceModelVersion>4.7.0</ServiceModelVersion>
<!-- We don't need to harvest the stable packages to build this -->
<HarvestStablePackage>false</HarvestStablePackage>
</PropertyGroup>
Expand All @@ -30,7 +30,7 @@
<PrereleaseLibraryPackage Include="System.Data.OleDb" />
<PrereleaseLibraryPackage Include="System.Data.SqlClient">
<!-- SQL client defines its own version, higher than rest of master -->
<Version>4.8.4</Version>
<Version>4.8.5</Version>
</PrereleaseLibraryPackage>
<PrereleaseLibraryPackage Include="System.Drawing.Common" />
<PrereleaseLibraryPackage Include="System.Diagnostics.EventLog" />
Expand Down
4 changes: 2 additions & 2 deletions src/System.Data.SqlClient/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<!-- Must be kept in sync with pkg\Microsoft.Windows.Compatibility\Microsoft.Windows.Compatibility.pkgproj -->
<PackageVersion>4.8.4</PackageVersion>
<AssemblyVersion>4.6.1.4</AssemblyVersion>
<PackageVersion>4.8.5</PackageVersion>
<AssemblyVersion>4.6.1.5</AssemblyVersion>
<!-- Downgrade the Assembly Version to match RTM in order to have System.Data shim to still
typeforward to RTM version instead of servicing version -->
<AssemblyVersion Condition="'$(TargetGroup)' == 'netcoreapp'">4.6.1.0</AssemblyVersion>
Expand Down
16 changes: 8 additions & 8 deletions src/System.Data.SqlClient/System.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ Global
{F3E72F35-0351-4D67-9388-725BCAD807BA}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{F3E72F35-0351-4D67-9388-725BCAD807BA}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{F3E72F35-0351-4D67-9388-725BCAD807BA}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{45DB5F86-7AE3-45C6-870D-F9357B66BDB5}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,7 @@ private void CleanUpStateObject(bool isCancelRequested = true)
{
_stateObj.CancelRequest();
}
_stateObj._internalTimeout = false;
_stateObj.SetTimeoutStateStopped();
_stateObj.CloseSession();
_stateObj._bulkCopyOpperationInProgress = false;
_stateObj._bulkCopyWriteTimeout = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ private bool TryCloseInternal(bool closeReader)
{
_sharedState._dataReady = true; // set _sharedState._dataReady to not confuse CleanPartialRead
}
_stateObj._internalTimeout = false;
_stateObj.SetTimeoutStateStopped();
if (_sharedState._dataReady)
{
cleanDataFailed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead
// If there is data ready, but we didn't exit the loop, then something is wrong
Debug.Assert(!dataReady, "dataReady not expected - did we forget to skip the row?");

if (stateObj._internalTimeout)
if (stateObj.IsTimeoutStateExpired)
{
runBehavior = RunBehavior.Attention;
}
Expand Down Expand Up @@ -2157,7 +2157,7 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead
stateObj._attentionSent = false;
stateObj._attentionReceived = false;

if (RunBehavior.Clean != (RunBehavior.Clean & runBehavior) && !stateObj._internalTimeout)
if (RunBehavior.Clean != (RunBehavior.Clean & runBehavior) && !stateObj.IsTimeoutStateExpired)
{
// Add attention error to collection - if not RunBehavior.Clean!
stateObj.AddError(new SqlError(0, 0, TdsEnums.MIN_ERROR_CLASS, _server, SQLMessage.OperationCancelled(), "", 0));
Expand Down
Loading

0 comments on commit 1acb337

Please sign in to comment.