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.
This commit is contained in:
Rob Shearman 2007-02-21 17:11:57 +00:00 committed by Alexandre Julliard
parent 272d7ab46a
commit ba590a185a
1 changed files with 6 additions and 14 deletions

View File

@ -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;