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

Alexandre Julliard julliard at wine.codeweavers.com
Wed Feb 21 13:18:38 CST 2007


Module: wine
Branch: master
Commit: ba590a185ae00c51ae10e5bc93938991330d79f8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ba590a185ae00c51ae10e5bc93938991330d79f8

Author: Rob Shearman <rob at codeweavers.com>
Date:   Wed Feb 21 17:11:57 2007 +0000

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 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c
index 2418b97..ec2b18d 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;




More information about the wine-cvs mailing list