[PATCH 6/8] secur32: Clear SECBUFFER_ALERT output buffer count in schan_InitializeSecurityContextW.

Connor McAdams cmcadams at codeweavers.com
Tue Jan 25 09:32:12 CST 2022


Since we write no data into this buffer, set the count to 0. Otherwise,
some applications assume there has been alert data written into the
buffer.

Signed-off-by: Connor McAdams <cmcadams at codeweavers.com>
---
 dlls/secur32/schannel.c       | 7 +++++++
 dlls/secur32/tests/schannel.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 19e21da8d72..2c328b96ce4 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -895,6 +895,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
         pInput->pBuffers[1].cbBuffer = pInput->pBuffers[0].cbBuffer-ctx->transport.in.offset;
     }
 
+    for (i = 0; i < pOutput->cBuffers; i++)
+    {
+        SecBuffer *buffer = &pOutput->pBuffers[i];
+        if (buffer->BufferType == SECBUFFER_ALERT && buffer->cbBuffer)
+            buffer->cbBuffer = 0;
+    }
+
     *pfContextAttr = ISC_RET_REPLAY_DETECT | ISC_RET_SEQUENCE_DETECT | ISC_RET_CONFIDENTIALITY | ISC_RET_STREAM;
     if (ctx->req_ctx_attr & ISC_REQ_EXTENDED_ERROR) *pfContextAttr |= ISC_RET_EXTENDED_ERROR;
     if (ctx->req_ctx_attr & ISC_REQ_DATAGRAM) *pfContextAttr |= ISC_RET_DATAGRAM;
diff --git a/dlls/secur32/tests/schannel.c b/dlls/secur32/tests/schannel.c
index 6c15addf2fc..6fbe0c34bd1 100644
--- a/dlls/secur32/tests/schannel.c
+++ b/dlls/secur32/tests/schannel.c
@@ -700,7 +700,7 @@ static void test_context_output_buffer_size(DWORD protocol, DWORD flags, ULONG c
         status = InitializeSecurityContextA(&cred_handle, NULL, (SEC_CHAR *)"localhost", ctxt_flags_req,
                 0, 0, &in_buffers, 0, &context, &out_buffers, &attrs, NULL);
         ok(status == SEC_I_CONTINUE_NEEDED, "%d: Expected SEC_I_CONTINUE_NEEDED, got %08x\n", i, status);
-        if (i) todo_wine ok(!buffer->cbBuffer, "Expected SECBUFFER_ALERT buffer to be empty\n");
+        if (i) ok(!buffer->cbBuffer, "Expected SECBUFFER_ALERT buffer to be empty\n");
         DeleteSecurityContext(&context);
     }
 
@@ -1661,7 +1661,7 @@ static void test_dtls(void)
     ok( !exp.LowPart, "got %08x\n", exp.LowPart );
     ok( !exp.HighPart, "got %08x\n", exp.HighPart );
     ok( buffers[1].pBuffers[1].BufferType == SECBUFFER_ALERT, "Expected buffertype SECBUFFER_ALERT, got %#x\n", buffers[1].pBuffers[1].BufferType);
-    todo_wine ok( !buffers[1].pBuffers[1].cbBuffer, "Expected SECBUFFER_ALERT buffer to be empty, got %#x\n", buffers[1].pBuffers[1].cbBuffer);
+    ok( !buffers[1].pBuffers[1].cbBuffer, "Expected SECBUFFER_ALERT buffer to be empty, got %#x\n", buffers[1].pBuffers[1].cbBuffer);
     prev_buf_len = buffers[1].pBuffers[0].cbBuffer;
 
     /*
-- 
2.25.1




More information about the wine-devel mailing list