secur32: Move the decrypt message receive loop to the Unix side.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-12-03 13:09:43 +01:00
parent 97ea9ee41c
commit 9894e109ac
2 changed files with 34 additions and 47 deletions

View File

@ -1319,7 +1319,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
SIZE_T data_size;
char *data;
unsigned expected_size;
SSIZE_T received = 0;
SIZE_T received = 0;
int idx;
unsigned char *buf_ptr;
@ -1360,31 +1360,14 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
init_schan_buffers(&ctx->transport.in, message, schan_decrypt_message_get_next_buffer);
ctx->transport.in.limit = expected_size;
while (received < data_size)
received = data_size;
status = schan_funcs->recv(ctx->transport.session, data, &received);
if (status != SEC_E_OK && status != SEC_I_RENEGOTIATE)
{
SIZE_T length = data_size - received;
status = schan_funcs->recv(ctx->transport.session, data + received, &length);
if (status == SEC_I_RENEGOTIATE)
break;
if (status == SEC_I_CONTINUE_NEEDED)
{
status = SEC_E_OK;
break;
}
if (status != SEC_E_OK)
{
free(data);
ERR("Returning %x\n", status);
return status;
}
if (!length)
break;
received += length;
free(data);
ERR("Returning %x\n", status);
return status;
}
TRACE("Received %ld bytes\n", received);

View File

@ -756,35 +756,39 @@ static SECURITY_STATUS CDECL schan_send(schan_session session, const void *buffe
static SECURITY_STATUS CDECL schan_recv(schan_session session, void *buffer, SIZE_T *length)
{
gnutls_session_t s = (gnutls_session_t)session;
size_t data_size = *length;
size_t received = 0;
ssize_t ret;
SECURITY_STATUS status = SEC_E_OK;
again:
ret = pgnutls_record_recv(s, buffer, *length);
if (ret >= 0)
*length = ret;
else if (ret == GNUTLS_E_AGAIN)
while (received < data_size)
{
struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s);
SIZE_T count = 0;
ret = pgnutls_record_recv(s, (char *)buffer + received, data_size - received);
if (get_buffer(t, &t->in, &count))
goto again;
if (ret > 0) received += ret;
else if (!ret) break;
else if (ret == GNUTLS_E_AGAIN)
{
struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s);
SIZE_T count = 0;
return SEC_I_CONTINUE_NEEDED;
}
else if (ret == GNUTLS_E_REHANDSHAKE)
{
TRACE("Rehandshake requested\n");
return SEC_I_RENEGOTIATE;
}
else
{
pgnutls_perror(ret);
return SEC_E_INTERNAL_ERROR;
if (!get_buffer(t, &t->in, &count)) break;
}
else if (ret == GNUTLS_E_REHANDSHAKE)
{
TRACE("Rehandshake requested\n");
status = SEC_I_RENEGOTIATE;
break;
}
else
{
pgnutls_perror(ret);
return SEC_E_INTERNAL_ERROR;
}
}
return SEC_E_OK;
*length = received;
return status;
}
static unsigned int parse_alpn_protocol_list(unsigned char *buffer, unsigned int buflen, gnutls_datum_t *list)