From ba590a185ae00c51ae10e5bc93938991330d79f8 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Wed, 21 Feb 2007 17:11:57 +0000 Subject: [PATCH] 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. --- dlls/wininet/netconnection.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index 2418b97467e..ec2b18dac4c 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c @@ -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; -- 2.11.4.GIT