Skip to content

Commit e52f1c3

Browse files
committed
set initial sendLength
1 parent 520a11b commit e52f1c3

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using System.Buffers;
76
using System.Runtime.InteropServices;
87
using System.Text;
98
using Microsoft.Data.Common;
@@ -472,8 +471,10 @@ internal static unsafe void SNIPacketSetData(SNIPacket packet, byte[] data, int
472471
}
473472
}
474473

475-
internal static unsafe uint SNISecGenClientContext(SNIHandle pConnectionObject, ReadOnlySpan<byte> inBuff, Span<byte> outBuff, ref uint sendLength, byte[] serverUserName)
474+
internal static unsafe uint SNISecGenClientContext(SNIHandle pConnectionObject, ReadOnlySpan<byte> inBuff, Span<byte> outBuff, out uint sendLength, byte[] serverUserName)
476475
{
476+
sendLength = (uint)outBuff.Length;
477+
477478
fixed (byte* pin_serverUserName = &serverUserName[0])
478479
fixed (byte* pInBuff = inBuff)
479480
fixed (byte* pOutBuff = outBuff)

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,10 @@ Int32[] passwordOffsets // Offset into data buffer where the password to be w
13811381
}
13821382
}
13831383

1384-
internal static unsafe uint SNISecGenClientContext(SNIHandle pConnectionObject, ReadOnlySpan<byte> inBuff, Span<byte> outBuff, ref uint sendLength, byte[] serverUserName)
1384+
internal static unsafe uint SNISecGenClientContext(SNIHandle pConnectionObject, ReadOnlySpan<byte> inBuff, Span<byte> outBuff, out uint sendLength, byte[] serverUserName)
13851385
{
1386+
sendLength = (uint)outBuff.Length;
1387+
13861388
fixed (byte* pin_serverUserName = &serverUserName[0])
13871389
{
13881390
bool local_fDone;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ protected override void GenerateSspiClientContext(ReadOnlyMemory<byte> incomingB
5959
#endif
6060

6161
var outBuff = outgoingBlobWriter.GetSpan((int)s_maxSSPILength);
62-
uint sendLength = 0;
6362

64-
if (0 != SNINativeMethodWrapper.SNISecGenClientContext(handle, incomingBlob.Span, outBuff, ref sendLength, _sniSpnBuffer[0]))
63+
if (0 != SNINativeMethodWrapper.SNISecGenClientContext(handle, incomingBlob.Span, outBuff, out var sendLength, _sniSpnBuffer[0]))
6564
{
6665
throw new InvalidOperationException(SQLMessage.SSPIGenerateError());
6766
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Buffers;
33
using System.Diagnostics;
4-
using Microsoft.IdentityModel.Tokens;
54

65
#nullable enable
76

0 commit comments

Comments
 (0)