Commit ba590a18 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

wininet: Fix the case of partial SSL reads from the peek buffer.

Don't return FALSE for a partial read. Fall through to SSL_read and use the logic for partial reads there instead of having separate logic and recursively calling NETCON_recv. Based on a patch by Michael Moss.
parent 272d7ab4
......@@ -497,12 +497,10 @@ BOOL NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len,
BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
int *recvd /* out */)
{
*recvd = 0;
if (!NETCON_connected(connection)) return FALSE;
if (!len)
{
*recvd = 0;
return TRUE;
}
if (!connection->useSSL)
{
*recvd = recv(connection->socketFD, buf, len, flags);
......@@ -543,19 +541,13 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
HeapFree(GetProcessHeap(), 0, connection->peek_msg_mem);
connection->peek_msg_mem = NULL;
connection->peek_msg = NULL;
/* check if the peek buffer held too few data */
if ((flags & MSG_WAITALL) && (*recvd < len))
{
int recv2 = 0;
/* recursive call - but now the peek buffer is empty */
if (!NETCON_recv(connection, (char*)buf + *recvd, len - *recvd, flags, &recv2))
return FALSE;
*recvd += recv2;
}
}
return TRUE;
/* check if we got enough data from the peek buffer */
if (!(flags & MSG_WAITALL) || (*recvd == len))
return TRUE;
/* otherwise, fall through */
}
*recvd = pSSL_read(connection->ssl_s, buf, len);
*recvd += pSSL_read(connection->ssl_s, (char*)buf + *recvd, len - *recvd);
if (flags & MSG_PEEK) /* must copy stuff into buffer */
{
connection->peek_len = *recvd;
......
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