Skip to content

Commit 74cb916

Browse files
cheenamalhotraFasjeit
authored andcommitted
Backport SqlClient 659 to release/3.1: Fix async timeout design leading 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.
1 parent 142c1f6 commit 74cb916

File tree

12 files changed

+402
-48
lines changed

12 files changed

+402
-48
lines changed

pkg/Microsoft.Private.PackageBaseline/packageIndex.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,10 @@
431431
"3.1.0",
432432
"3.1.1",
433433
"3.1.2",
434-
"3.1.3"
434+
"3.1.3",
435+
"3.1.4"
435436
],
436-
"BaselineVersion": "3.1.3",
437+
"BaselineVersion": "3.1.4",
437438
"InboxOn": {}
438439
},
439440
"Microsoft.Windows.Compatibility.Shims": {
@@ -1553,9 +1554,10 @@
15531554
"4.8.1",
15541555
"4.8.2",
15551556
"4.8.3",
1556-
"4.8.4"
1557+
"4.8.4",
1558+
"4.8.5"
15571559
],
1558-
"BaselineVersion": "4.8.4",
1560+
"BaselineVersion": "4.8.5",
15591561
"InboxOn": {
15601562
"net461": "4.1.0.0",
15611563
"monoandroid10": "Any",
@@ -1580,7 +1582,8 @@
15801582
"4.6.1.1": "4.8.1",
15811583
"4.6.1.2": "4.8.2",
15821584
"4.6.1.3": "4.8.3",
1583-
"4.6.1.4": "4.8.4"
1585+
"4.6.1.4": "4.8.4",
1586+
"4.6.1.5": "4.8.5"
15841587
}
15851588
},
15861589
"System.Data.SqlXml": {

pkg/Microsoft.Windows.Compatibility/Microsoft.Windows.Compatibility.pkgproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<!-- We use the PackageVersion property defined in Packaging.props for the Prerelease packages which are using it to be built -->
55
<_PreReleasePackageVersion>$(PackageVersion)</_PreReleasePackageVersion>
6-
<PackageVersion>3.1.3</PackageVersion>
7-
<ServiceModelVersion>4.7.1</ServiceModelVersion>
6+
<PackageVersion>3.1.4</PackageVersion>
7+
<ServiceModelVersion>4.7.0</ServiceModelVersion>
88
<!-- We don't need to harvest the stable packages to build this -->
99
<HarvestStablePackage>false</HarvestStablePackage>
1010
</PropertyGroup>
@@ -30,7 +30,7 @@
3030
<PrereleaseLibraryPackage Include="System.Data.OleDb" />
3131
<PrereleaseLibraryPackage Include="System.Data.SqlClient">
3232
<!-- SQL client defines its own version, higher than rest of master -->
33-
<Version>4.8.4</Version>
33+
<Version>4.8.5</Version>
3434
</PrereleaseLibraryPackage>
3535
<PrereleaseLibraryPackage Include="System.Drawing.Common" />
3636
<PrereleaseLibraryPackage Include="System.Diagnostics.EventLog" />

src/System.Data.SqlClient/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<Import Project="..\Directory.Build.props" />
33
<PropertyGroup>
44
<!-- Must be kept in sync with pkg\Microsoft.Windows.Compatibility\Microsoft.Windows.Compatibility.pkgproj -->
5-
<PackageVersion>4.8.4</PackageVersion>
6-
<AssemblyVersion>4.6.1.4</AssemblyVersion>
5+
<PackageVersion>4.8.5</PackageVersion>
6+
<AssemblyVersion>4.6.1.5</AssemblyVersion>
77
<!-- Downgrade the Assembly Version to match RTM in order to have System.Data shim to still
88
typeforward to RTM version instead of servicing version -->
99
<AssemblyVersion Condition="'$(TargetGroup)' == 'netcoreapp'">4.6.1.0</AssemblyVersion>

src/System.Data.SqlClient/System.Data.SqlClient.sln

+8-8
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ Global
9090
{F3E72F35-0351-4D67-9388-725BCAD807BA}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
9191
{F3E72F35-0351-4D67-9388-725BCAD807BA}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
9292
{F3E72F35-0351-4D67-9388-725BCAD807BA}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
93-
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
94-
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
93+
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
94+
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
9595
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
9696
{D1392B54-998A-4F27-BC17-4CE149117BCC}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
97-
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
98-
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
97+
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
98+
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
9999
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
100100
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
101-
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
102-
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
101+
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
102+
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
103103
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
104104
{B73A7063-37C3-415D-AD53-BB3DA20ABD6E}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
105-
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
106-
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
105+
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
106+
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
107107
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
108108
{E0A6BB21-574B-43D9-890D-6E1144F2EE9E}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
109109
{45DB5F86-7AE3-45C6-870D-F9357B66BDB5}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU

src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,7 @@ private void CleanUpStateObject(bool isCancelRequested = true)
25982598
{
25992599
_stateObj.CancelRequest();
26002600
}
2601-
_stateObj._internalTimeout = false;
2601+
_stateObj.SetTimeoutStateStopped();
26022602
_stateObj.CloseSession();
26032603
_stateObj._bulkCopyOpperationInProgress = false;
26042604
_stateObj._bulkCopyWriteTimeout = false;

src/System.Data.SqlClient/src/System/Data/SqlClient/SqlDataReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ private bool TryCloseInternal(bool closeReader)
892892
{
893893
_sharedState._dataReady = true; // set _sharedState._dataReady to not confuse CleanPartialRead
894894
}
895-
_stateObj._internalTimeout = false;
895+
_stateObj.SetTimeoutStateStopped();
896896
if (_sharedState._dataReady)
897897
{
898898
cleanDataFailed = true;

src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead
15901590
// If there is data ready, but we didn't exit the loop, then something is wrong
15911591
Debug.Assert(!dataReady, "dataReady not expected - did we forget to skip the row?");
15921592

1593-
if (stateObj._internalTimeout)
1593+
if (stateObj.IsTimeoutStateExpired)
15941594
{
15951595
runBehavior = RunBehavior.Attention;
15961596
}
@@ -2157,7 +2157,7 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead
21572157
stateObj._attentionSent = false;
21582158
stateObj._attentionReceived = false;
21592159

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

0 commit comments

Comments
 (0)