winhttp: Don't allow socket transfers after receiving close frame.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
41ea7fb0e1
commit
04fcadacca
|
@ -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") );
|
||||
|
|
Loading…
Reference in New Issue