Commit 04fcadac authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Don't allow socket transfers after receiving close frame.

parent 41ea7fb0
......@@ -3287,6 +3287,16 @@ static BOOL receive_io_complete( struct socket *socket )
return count >= 0;
}
static BOOL socket_can_send( struct socket *socket )
{
return socket->state == SOCKET_STATE_OPEN && !socket->close_frame_received;
}
static BOOL socket_can_receive( struct socket *socket )
{
return socket->state <= SOCKET_STATE_SHUTDOWN && !socket->close_frame_received;
}
static enum socket_opcode map_buffer_type( WINHTTP_WEB_SOCKET_BUFFER_TYPE type )
{
switch (type)
......@@ -3364,7 +3374,7 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE;
}
if (socket->state != SOCKET_STATE_OPEN)
if (!socket_can_send( socket ))
{
release_object( &socket->hdr );
return ERROR_INVALID_OPERATION;
......@@ -3723,7 +3733,7 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
release_object( &socket->hdr );
return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE;
}
if (socket->state > SOCKET_STATE_SHUTDOWN)
if (!socket_can_receive( socket ))
{
release_object( &socket->hdr );
return ERROR_INVALID_OPERATION;
......
......@@ -1132,6 +1132,9 @@ static void test_websocket(BOOL secure)
ok( close_status == 1000, "got %u\n", close_status );
ok( size <= sizeof(buffer), "got %u\n", size );
err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type );
ok( err == ERROR_INVALID_OPERATION, "got %u\n", err );
info.buflen = 0xdeadbeef;
setup_test( &info, winhttp_websocket_close, __LINE__ );
err = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") );
......
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