Skip to content

Commit 266cf7f

Browse files
committed
switch to span
1 parent d3bd2b9 commit 266cf7f

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal class SNIProxy
3535
/// <param name="sendWriter">Writer for send buffer</param>
3636
/// <param name="serverName">Service Principal Name buffer</param>
3737
/// <returns>SNI error code</returns>
38-
internal static void GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, ReadOnlyMemory<byte> receivedBuff, IBufferWriter<byte> sendWriter, byte[][] serverName)
38+
internal static void GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> sendWriter, byte[][] serverName)
3939
{
4040
// TODO: this should use ReadOnlyMemory all the way through
4141
byte[] array = null;

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, byte[][] _sniSpnBuffer)
15+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer)
1616
{
1717
_sspiClientContextStatus ??= new SspiClientContextStatus();
1818
SNIProxy.GenSspiClientContext(_sspiClientContextStatus, incomingBlob, outgoingBlobWriter, _sniSpnBuffer);

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, byte[][] _sniSpnBuffer)
52+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer)
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, _sniSpnBuffer[0]))
63+
if (0 != SNINativeMethodWrapper.SNISecGenClientContext(handle, incomingBlob, outBuff, out var sendLength, _sniSpnBuffer[0]))
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
@@ -11,14 +11,14 @@ namespace Microsoft.Data.SqlClient
1111
{
1212
internal sealed class NegotiateSSPIContextProvider : SSPIContextProvider
1313
{
14-
protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer)
14+
protected override void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer)
1515
{
1616
NegotiateAuthenticationStatusCode statusCode = default;
1717

1818
for (int i = 0; i < _sniSpnBuffer.Length; i++)
1919
{
2020
var negotiateAuth = new NegotiateAuthentication(new NegotiateAuthenticationClientOptions { Package = "Negotiate", TargetName = Encoding.Unicode.GetString(_sniSpnBuffer[i]) });
21-
var result = negotiateAuth.GetOutgoingBlob(incomingBlob.Span, out statusCode);
21+
var result = negotiateAuth.GetOutgoingBlob(incomingBlob, out statusCode);
2222

2323
// Log session id, status code and the actual SPN used in the negotiation
2424
SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | Session Id {2}, StatusCode={3}, SPN={4}", nameof(NegotiateSSPIContextProvider),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ private protected virtual void Initialize()
2626
{
2727
}
2828

29-
protected abstract void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer);
29+
protected abstract void GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlob, IBufferWriter<byte> outgoingBlobWriter, byte[][] _sniSpnBuffer);
3030

31-
internal void SSPIData(ReadOnlyMemory<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, byte[] sniSpnBuffer)
31+
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, byte[] sniSpnBuffer)
3232
=> SSPIData(receivedBuff, outgoingBlobWriter, new[] { sniSpnBuffer });
3333

34-
internal void SSPIData(ReadOnlyMemory<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, byte[][] sniSpnBuffer)
34+
internal void SSPIData(ReadOnlySpan<byte> receivedBuff, IBufferWriter<byte> outgoingBlobWriter, byte[][] sniSpnBuffer)
3535
{
3636
using (TrySNIEventScope.Create(nameof(SSPIContextProvider)))
3737
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal void ProcessSSPI(int receivedLength)
3131
var writer = _writers.Rent();
3232

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

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

194194
_physicalStateObj.SniContext = SniContext.Snix_Login;
195195

0 commit comments

Comments
 (0)