Skip to content

Commit 4ae807b

Browse files
committed
use ReadOnlySpan
1 parent de0c27b commit 4ae807b

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ internal class SNIProxy
3636
/// <param name="sendWriter">Writer for send buffer</param>
3737
/// <param name="serverNames">Service Principal Name</param>
3838
/// <returns>SNI error code</returns>
39-
internal static void GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, ReadOnlyMemory<byte> receivedBuff, IBufferWriter<byte> sendWriter, string[] serverNames)
39+
internal static void GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> sendWriter, string[] serverNames)
4040
{
41-
// TODO: this should use ReadOnlyMemory all the way through
41+
// TODO: this should use ReadOnlySpan all the way through
4242
byte[] array = null;
4343

4444
if (!receivedBuff.IsEmpty)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/ManagedSSPIContextProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal sealed class ManagedSSPIContextProvider : SSPIContextProvider
1212
{
1313
private SspiClientContextStatus? _sspiClientContextStatus;
1414

15-
protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter)
15+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter)
1616
{
1717
_sspiClientContextStatus ??= new SspiClientContextStatus();
1818

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSSPIContextProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void LoadSSPILibrary()
4949
}
5050
}
5151

52-
protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter)
52+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter)
5353
{
5454
#if NETFRAMEWORK
5555
SNIHandle handle = _physicalStateObj.Handle;
@@ -60,7 +60,7 @@ protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingB
6060

6161
var outBuff = outgoingBlobWriter.GetSpan((int)s_maxSSPILength);
6262

63-
if (0 != SNINativeMethodWrapper.SNISecGenClientContext(handle, incomingBlob.Span, outBuff, out var sendLength, AuthenticationParameters.ServerName))
63+
if (0 != SNINativeMethodWrapper.SNISecGenClientContext(handle, incomingBlob, outBuff, out var sendLength, AuthenticationParameters.ServerName))
6464
{
6565
throw new InvalidOperationException(SQLMessage.SSPIGenerateError());
6666
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSSPIContextProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ internal sealed class NegotiateSSPIContextProvider : SSPIContextProvider
1313
{
1414
private NegotiateAuthentication? _negotiateAuth = null;
1515

16-
protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter)
16+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter)
1717
{
1818
_negotiateAuth ??= new(new NegotiateAuthenticationClientOptions { Package = "Negotiate", TargetName = AuthenticationParameters.ServerName });
19-
var result = _negotiateAuth.GetOutgoingBlob(incomingBlob.Span, out NegotiateAuthenticationStatusCode statusCode)!;
19+
var result = _negotiateAuth.GetOutgoingBlob(incomingBlob, out NegotiateAuthenticationStatusCode statusCode)!;
2020
SqlClientEventSource.Log.TryTraceEvent("TdsParserStateObjectManaged.GenerateSspiClientContext | Info | Session Id {0}, StatusCode={1}", _physicalStateObj.SessionId, statusCode);
2121
if (statusCode is not NegotiateAuthenticationStatusCode.Completed and not NegotiateAuthenticationStatusCode.ContinueNeeded)
2222
{

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ private protected virtual void Initialize()
6060
/// </summary>
6161
protected SqlAuthenticationParameters AuthenticationParameters => _parameters ?? throw new InvalidOperationException("SSPI context provider has not been initialized");
6262

63-
protected abstract void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter);
63+
protected abstract void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter);
6464

65-
internal void SSPIData(ReadOnlyMemory<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter)
65+
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter)
6666
{
6767
try
6868
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal void ProcessSSPI(int receivedLength)
2929
var writer = SqlObjectPools.BufferWriter.Rent();
3030

3131
// make call for SSPI data
32-
_authenticationProvider!.SSPIData(receivedBuff.AsMemory(0, receivedLength), writer);
32+
_authenticationProvider!.SSPIData(receivedBuff.AsSpan(0, receivedLength), writer);
3333

3434
// DO NOT SEND LENGTH - TDS DOC INCORRECT! JUST SEND SSPI DATA!
3535
_physicalStateObj.WriteByteSpan(writer.WrittenSpan);
@@ -187,7 +187,7 @@ internal void TdsLogin(
187187
// byte[] buffer and 0 for the int length.
188188
Debug.Assert(SniContext.Snix_Login == _physicalStateObj.SniContext, $"Unexpected SniContext. Expecting Snix_Login, actual value is '{_physicalStateObj.SniContext}'");
189189
_physicalStateObj.SniContext = SniContext.Snix_LoginSspi;
190-
_authenticationProvider.SSPIData(ReadOnlyMemory<byte>.Empty, sspiWriter);
190+
_authenticationProvider.SSPIData(ReadOnlySpan<byte>.Empty, sspiWriter);
191191

192192
_physicalStateObj.SniContext = SniContext.Snix_Login;
193193

0 commit comments

Comments
 (0)