Skip to content

Commit fbd62e0

Browse files
committed
initialization only after success
1 parent b375f91 commit fbd62e0

File tree

2 files changed

+16
-20
lines changed
  • src/Microsoft.Data.SqlClient

2 files changed

+16
-20
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ internal void Connect(ServerInfo serverInfo,
459459
hostNameInCertificate,
460460
serverCertificateFilename);
461461

462-
_authenticationProvider?.Initialize(serverInfo, _physicalStateObj, this, _serverSpn);
463-
464462
if (TdsEnums.SNI_SUCCESS != _physicalStateObj.Status)
465463
{
466464
_physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
@@ -559,8 +557,6 @@ internal void Connect(ServerInfo serverInfo,
559557
hostNameInCertificate,
560558
serverCertificateFilename);
561559

562-
_authenticationProvider?.Initialize(serverInfo, _physicalStateObj, this, _serverSpn);
563-
564560
if (TdsEnums.SNI_SUCCESS != _physicalStateObj.Status)
565561
{
566562
_physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
@@ -599,6 +595,8 @@ internal void Connect(ServerInfo serverInfo,
599595
}
600596
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Prelogin handshake successful");
601597

598+
_authenticationProvider?.Initialize(serverInfo, _physicalStateObj, this, _serverSpn);
599+
602600
if (_fMARS && marsCapable)
603601
{
604602
// if user explicitly disables mars or mars not supported, don't create the session pool
@@ -744,7 +742,7 @@ private void SendPreLoginHandshake(
744742

745743
// UNDONE - need to do some length verification to ensure packet does not
746744
// get too big!!! Not beyond it's max length!
747-
745+
748746
for (int option = (int)PreLoginOptions.VERSION; option < (int)PreLoginOptions.NUMOPT; option++)
749747
{
750748
int optionDataSize = 0;
@@ -935,7 +933,7 @@ private PreLoginHandshakeStatus ConsumePreLoginHandshake(
935933
string serverCertificateFilename)
936934
{
937935
// Assign default values
938-
marsCapable = _fMARS;
936+
marsCapable = _fMARS;
939937
fedAuthRequired = false;
940938
Debug.Assert(_physicalStateObj._syncOverAsync, "Should not attempt pends in a synchronous call");
941939
TdsOperationStatus result = _physicalStateObj.TryReadNetworkPacket();
@@ -2181,7 +2179,7 @@ internal TdsOperationStatus TryRun(RunBehavior runBehavior, SqlCommand cmdHandle
21812179
dataStream.BrowseModeInfoConsumed = true;
21822180
}
21832181
else
2184-
{
2182+
{
21852183
// no dataStream
21862184
result = stateObj.TrySkipBytes(tokenLength);
21872185
if (result != TdsOperationStatus.Done)
@@ -2195,7 +2193,7 @@ internal TdsOperationStatus TryRun(RunBehavior runBehavior, SqlCommand cmdHandle
21952193
case TdsEnums.SQLDONE:
21962194
case TdsEnums.SQLDONEPROC:
21972195
case TdsEnums.SQLDONEINPROC:
2198-
{
2196+
{
21992197
// RunBehavior can be modified - see SQL BU DT 269516 & 290090
22002198
result = TryProcessDone(cmdHandler, dataStream, ref runBehavior, stateObj);
22012199
if (result != TdsOperationStatus.Done)
@@ -4122,7 +4120,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
41224120
{
41234121
return result;
41244122
}
4125-
4123+
41264124
byte len;
41274125
result = stateObj.TryReadByte(out len);
41284126
if (result != TdsOperationStatus.Done)
@@ -4321,7 +4319,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,
43214319
{
43224320
return result;
43234321
}
4324-
4322+
43254323
if (rec.collation.IsUTF8)
43264324
{ // UTF8 collation
43274325
rec.encoding = Encoding.UTF8;
@@ -4776,13 +4774,13 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
47764774
{
47774775
// internal meta data class
47784776
_SqlMetaData col = altMetaDataSet[i];
4779-
4777+
47804778
result = stateObj.TryReadByte(out _);
47814779
if (result != TdsOperationStatus.Done)
47824780
{
47834781
return result;
47844782
}
4785-
4783+
47864784
result = stateObj.TryReadUInt16(out _);
47874785
if (result != TdsOperationStatus.Done)
47884786
{
@@ -5466,7 +5464,7 @@ private TdsOperationStatus TryProcessColInfo(_SqlMetaDataSet columns, SqlDataRea
54665464
for (int i = 0; i < columns.Length; i++)
54675465
{
54685466
_SqlMetaData col = columns[i];
5469-
5467+
54705468
TdsOperationStatus result = stateObj.TryReadByte(out _);
54715469
if (result != TdsOperationStatus.Done)
54725470
{
@@ -7386,7 +7384,7 @@ private byte[] SerializeSqlMoney(SqlMoney value, int length, TdsParserStateObjec
73867384

73877385
private void WriteSqlMoney(SqlMoney value, int length, TdsParserStateObject stateObj)
73887386
{
7389-
// UNDONE: can I use SqlMoney.ToInt64()?
7387+
// UNDONE: can I use SqlMoney.ToInt64()?
73907388
int[] bits = decimal.GetBits(value.Value);
73917389

73927390
// this decimal should be scaled by 10000 (regardless of what the incoming decimal was scaled by)
@@ -9906,7 +9904,7 @@ private Task TDSExecuteRPCAddParameter(TdsParserStateObject stateObj, SqlParamet
99069904

99079905
WriteUDTMetaData(value, names[0], names[1], names[2], stateObj);
99089906

9909-
// UNDONE - re-org to use code below to write value!
9907+
// UNDONE - re-org to use code below to write value!
99109908
if (!isNull)
99119909
{
99129910
WriteUnsignedLong((ulong)udtVal.Length, stateObj); // PLP length
@@ -12340,7 +12338,7 @@ private Task WriteUnterminatedValue(object value, MetaType type, byte scale, int
1234012338
case TdsEnums.SQLNVARCHAR:
1234112339
case TdsEnums.SQLNTEXT:
1234212340
case TdsEnums.SQLXMLTYPE:
12343-
case TdsEnums.SQLJSON:
12341+
case TdsEnums.SQLJSON:
1234412342
{
1234512343
Debug.Assert(!isDataFeed || (value is TextDataFeed || value is XmlDataFeed), "Value must be a TextReader or XmlReader");
1234612344
Debug.Assert(isDataFeed || (value is string || value is byte[]), "Value is a byte array or string");

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,6 @@ internal void Connect(ServerInfo serverInfo,
518518
FQDNforDNSCache,
519519
hostNameInCertificate);
520520

521-
_authenticationProvider?.Initialize(serverInfo, _physicalStateObj, this, _serverSpn);
522-
523521
if (TdsEnums.SNI_SUCCESS != _physicalStateObj.Status)
524522
{
525523
_physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
@@ -612,8 +610,6 @@ internal void Connect(ServerInfo serverInfo,
612610
serverInfo.ResolvedServerName,
613611
hostNameInCertificate);
614612

615-
_authenticationProvider?.Initialize(serverInfo, _physicalStateObj, this, _serverSpn);
616-
617613
if (TdsEnums.SNI_SUCCESS != _physicalStateObj.Status)
618614
{
619615
_physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
@@ -648,6 +644,8 @@ internal void Connect(ServerInfo serverInfo,
648644
}
649645
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Prelogin handshake successful");
650646

647+
_authenticationProvider?.Initialize(serverInfo, _physicalStateObj, this, _serverSpn);
648+
651649
if (_fMARS && marsCapable)
652650
{
653651
// if user explicitly disables mars or mars not supported, don't create the session pool

0 commit comments

Comments
 (0)