mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 05:57:27 +00:00
secur32: Pass single input and output buffers for handshake call.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
c1d9d6e06e
commit
fee52bd43c
|
@ -767,6 +767,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
|
|||
int output_buffer_idx = -1;
|
||||
int idx, i;
|
||||
ULONG input_offset = 0, output_offset = 0;
|
||||
SecBufferDesc input_desc, output_desc;
|
||||
|
||||
TRACE("%p %p %s 0x%08lx %ld %ld %p %ld %p %p %p %p\n", phCredential, phContext,
|
||||
debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
|
||||
|
@ -917,11 +918,30 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
|
|||
alloc_buffer.BufferType = SECBUFFER_TOKEN;
|
||||
alloc_buffer.pvBuffer = RtlAllocateHeap( GetProcessHeap(), 0, extra_size );
|
||||
}
|
||||
|
||||
memset(&input_desc, 0, sizeof(input_desc));
|
||||
if (pInput && (idx = schan_find_sec_buffer_idx(pInput, 0, SECBUFFER_TOKEN)) != -1)
|
||||
{
|
||||
input_desc.cBuffers = 1;
|
||||
input_desc.pBuffers = &pInput->pBuffers[idx];
|
||||
}
|
||||
|
||||
memset(&output_desc, 0, sizeof(output_desc));
|
||||
idx = schan_find_sec_buffer_idx(pOutput, 0, SECBUFFER_TOKEN);
|
||||
if (idx == -1)
|
||||
idx = schan_find_sec_buffer_idx(pOutput, 0, SECBUFFER_EMPTY);
|
||||
if (idx != -1)
|
||||
{
|
||||
output_desc.cBuffers = 1;
|
||||
output_desc.pBuffers = &pOutput->pBuffers[idx];
|
||||
if (!output_desc.pBuffers->pvBuffer)
|
||||
output_desc.pBuffers = &alloc_buffer;
|
||||
}
|
||||
|
||||
params.session = ctx->session;
|
||||
params.input = pInput;
|
||||
params.input = pInput ? &input_desc : NULL;
|
||||
params.input_size = expected_size;
|
||||
params.output = pOutput;
|
||||
params.alloc_buffer = &alloc_buffer;
|
||||
params.output = &output_desc;
|
||||
params.input_offset = &input_offset;
|
||||
params.output_buffer_idx = &output_buffer_idx;
|
||||
params.output_offset = &output_offset;
|
||||
|
@ -929,12 +949,15 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
|
|||
|
||||
if (output_buffer_idx != -1)
|
||||
{
|
||||
SecBuffer *buffer = &pOutput->pBuffers[output_buffer_idx];
|
||||
SecBuffer *buffer = &pOutput->pBuffers[idx];
|
||||
buffer->BufferType = SECBUFFER_TOKEN;
|
||||
buffer->cbBuffer = output_offset;
|
||||
if (buffer->pvBuffer == alloc_buffer.pvBuffer)
|
||||
if (output_desc.pBuffers == &alloc_buffer)
|
||||
{
|
||||
RtlReAllocateHeap( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY,
|
||||
buffer->pvBuffer, buffer->cbBuffer );
|
||||
alloc_buffer.pvBuffer, buffer->cbBuffer );
|
||||
|
||||
buffer->pvBuffer = alloc_buffer.pvBuffer;
|
||||
alloc_buffer.pvBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,6 @@ struct schan_buffers
|
|||
SIZE_T offset;
|
||||
SIZE_T limit;
|
||||
const SecBufferDesc *desc;
|
||||
SecBuffer *alloc_buffer;
|
||||
int current_buffer_idx;
|
||||
int (*get_next_buffer)(struct schan_buffers *);
|
||||
};
|
||||
|
@ -234,7 +233,6 @@ static void init_schan_buffers(struct schan_buffers *s, const PSecBufferDesc des
|
|||
s->limit = ~0UL;
|
||||
s->desc = desc;
|
||||
s->current_buffer_idx = -1;
|
||||
s->alloc_buffer = NULL;
|
||||
s->get_next_buffer = get_next_buffer;
|
||||
}
|
||||
|
||||
|
@ -257,26 +255,7 @@ static int handshake_get_next_buffer(struct schan_buffers *s)
|
|||
{
|
||||
if (s->current_buffer_idx != -1)
|
||||
return -1;
|
||||
return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_TOKEN);
|
||||
}
|
||||
|
||||
static int handshake_get_next_buffer_alloc(struct schan_buffers *s)
|
||||
{
|
||||
if (s->current_buffer_idx == -1)
|
||||
{
|
||||
int idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_TOKEN);
|
||||
if (idx == -1)
|
||||
{
|
||||
idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_EMPTY);
|
||||
if (idx != -1) s->desc->pBuffers[idx].BufferType = SECBUFFER_TOKEN;
|
||||
}
|
||||
if (idx != -1 && !s->desc->pBuffers[idx].pvBuffer && s->alloc_buffer)
|
||||
{
|
||||
s->desc->pBuffers[idx] = *s->alloc_buffer;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
return -1;
|
||||
return s->desc->cBuffers ? 0 : -1;
|
||||
}
|
||||
|
||||
static int send_message_get_next_buffer(struct schan_buffers *s)
|
||||
|
@ -606,8 +585,7 @@ static NTSTATUS schan_handshake( void *args )
|
|||
|
||||
init_schan_buffers(&t->in, params->input, handshake_get_next_buffer);
|
||||
t->in.limit = params->input_size;
|
||||
init_schan_buffers(&t->out, params->output, handshake_get_next_buffer_alloc );
|
||||
t->out.alloc_buffer = params->alloc_buffer;
|
||||
init_schan_buffers(&t->out, params->output, handshake_get_next_buffer);
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
|
|
@ -147,7 +147,6 @@ struct handshake_params
|
|||
SecBufferDesc *input;
|
||||
SIZE_T input_size;
|
||||
SecBufferDesc *output;
|
||||
SecBuffer *alloc_buffer;
|
||||
ULONG *input_offset;
|
||||
int *output_buffer_idx;
|
||||
ULONG *output_offset;
|
||||
|
|
Loading…
Reference in a new issue