Skip to content

Commit db5d4df

Browse files
Fix incorrect buffer reallocation in AcceptSecurityContext (#72339)
Co-authored-by: Filip Navara <[email protected]>
1 parent 3b0a075 commit db5d4df

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,13 @@ internal static unsafe int AcceptSecurityContext(
783783

784784
outSecBuffer.size = outUnmanagedBuffer[index].cbBuffer;
785785
outSecBuffer.type = outUnmanagedBuffer[index].BufferType;
786-
outSecBuffer.token = outSecBuffer.size > 0 ?
787-
new Span<byte>((byte*)outUnmanagedBuffer[index].pvBuffer, outUnmanagedBuffer[0].cbBuffer).ToArray() :
788-
null;
786+
787+
if (isSspiAllocated)
788+
{
789+
outSecBuffer.token = outSecBuffer.size > 0 ?
790+
new Span<byte>((byte*)outUnmanagedBuffer[index].pvBuffer, outUnmanagedBuffer[0].cbBuffer).ToArray() :
791+
null;
792+
}
789793

790794
if (inSecBuffers.Count > 1 && inUnmanagedBuffer[1].BufferType == SecurityBufferType.SECBUFFER_EXTRA && inSecBuffers._item1.Type == SecurityBufferType.SECBUFFER_EMPTY)
791795
{

0 commit comments

Comments
 (0)