[PATCH 1/5] winhttp: Append mask to output frame even if buffer length is zero.

Paul Gofman pgofman at codeweavers.com
Wed Jan 26 17:03:05 CST 2022


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
     Supersedes 224517.

     That patch turned out to be completely off. After watching the packets from my external test on Windows
     it turned out the pongs are actually send. The culprit is that while they also have zero length
     application data they still have mask bit set (like we do) and mask appended (like we don't do).
     As I read rfc6455, p 5.2, the mask presence is controlled solely by the mask bit and there is no mention
     of a special case for zero length application data. It stated also that "All frames sent from
     client to server have this bit set to 1.", no exception is given.


 dlls/winhttp/request.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index cbfe2b21bd0..0a5362d3c16 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -3174,8 +3174,7 @@ static DWORD send_frame( struct socket *socket, enum socket_opcode opcode, USHOR
         offset += 8;
     }
 
-    buffer_size = len + offset;
-    if (len) buffer_size += 4;
+    buffer_size = len + offset + 4;
     assert( buffer_size - len < MAX_FRAME_BUFFER_SIZE );
     if (ovr && buffer_size > MAX_FRAME_BUFFER_SIZE) return WSAEWOULDBLOCK;
     if (buffer_size > socket->send_frame_buffer_size && socket->send_frame_buffer_size < MAX_FRAME_BUFFER_SIZE)
@@ -3196,13 +3195,11 @@ static DWORD send_frame( struct socket *socket, enum socket_opcode opcode, USHOR
 
     memcpy(ptr, hdr, offset);
     ptr += offset;
-    if (len)
-    {
-        mask = &hdr[offset];
-        RtlGenRandom( mask, 4 );
-        memcpy( ptr, mask, 4 );
-        ptr += 4;
-    }
+
+    mask = &hdr[offset];
+    RtlGenRandom( mask, 4 );
+    memcpy( ptr, mask, 4 );
+    ptr += 4;
 
     if (opcode == SOCKET_OPCODE_CLOSE) /* prepend status code */
     {
-- 
2.34.1




More information about the wine-devel mailing list