Commit 9894e109 authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent 97ea9ee4
...@@ -1319,7 +1319,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle ...@@ -1319,7 +1319,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
SIZE_T data_size; SIZE_T data_size;
char *data; char *data;
unsigned expected_size; unsigned expected_size;
SSIZE_T received = 0; SIZE_T received = 0;
int idx; int idx;
unsigned char *buf_ptr; unsigned char *buf_ptr;
...@@ -1360,31 +1360,14 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle ...@@ -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); init_schan_buffers(&ctx->transport.in, message, schan_decrypt_message_get_next_buffer);
ctx->transport.in.limit = expected_size; ctx->transport.in.limit = expected_size;
while (received < data_size) received = data_size;
{ status = schan_funcs->recv(ctx->transport.session, data, &received);
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) if (status != SEC_E_OK && status != SEC_I_RENEGOTIATE)
{ {
free(data); free(data);
ERR("Returning %x\n", status); ERR("Returning %x\n", status);
return status; return status;
}
if (!length)
break;
received += length;
} }
TRACE("Received %ld bytes\n", received); TRACE("Received %ld bytes\n", received);
......
...@@ -756,35 +756,39 @@ static SECURITY_STATUS CDECL schan_send(schan_session session, const void *buffe ...@@ -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) static SECURITY_STATUS CDECL schan_recv(schan_session session, void *buffer, SIZE_T *length)
{ {
gnutls_session_t s = (gnutls_session_t)session; gnutls_session_t s = (gnutls_session_t)session;
size_t data_size = *length;
size_t received = 0;
ssize_t ret; ssize_t ret;
SECURITY_STATUS status = SEC_E_OK;
again: while (received < data_size)
ret = pgnutls_record_recv(s, buffer, *length);
if (ret >= 0)
*length = ret;
else if (ret == GNUTLS_E_AGAIN)
{ {
struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s); ret = pgnutls_record_recv(s, (char *)buffer + received, data_size - received);
SIZE_T count = 0;
if (get_buffer(t, &t->in, &count)) if (ret > 0) received += ret;
goto again; 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; if (!get_buffer(t, &t->in, &count)) break;
} }
else if (ret == GNUTLS_E_REHANDSHAKE) else if (ret == GNUTLS_E_REHANDSHAKE)
{ {
TRACE("Rehandshake requested\n"); TRACE("Rehandshake requested\n");
return SEC_I_RENEGOTIATE; status = SEC_I_RENEGOTIATE;
} break;
else }
{ else
pgnutls_perror(ret); {
return SEC_E_INTERNAL_ERROR; 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) static unsigned int parse_alpn_protocol_list(unsigned char *buffer, unsigned int buflen, gnutls_datum_t *list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment