Commit 968b3745 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Status and reason are optional in the close response.

parent b9038c73
......@@ -3310,7 +3310,7 @@ static DWORD receive_bytes( struct netconn *netconn, char *buf, DWORD len, DWORD
{
DWORD err;
if ((err = netconn_recv( netconn, buf, len, 0, (int *)ret_len ))) return err;
if (len && !*ret_len) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
if (*ret_len != len) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
return ERROR_SUCCESS;
}
......@@ -3341,8 +3341,7 @@ static DWORD receive_frame( struct netconn *netconn, DWORD *ret_len, enum socket
char hdr[2];
if ((ret = receive_bytes( netconn, hdr, sizeof(hdr), &count ))) return ret;
if (count != sizeof(hdr) || (hdr[0] & RESERVED_BIT) || (hdr[1] & MASK_BIT) ||
(map_opcode( hdr[0] & 0xf, FALSE ) == ~0u))
if ((hdr[0] & RESERVED_BIT) || (hdr[1] & MASK_BIT) || (map_opcode( hdr[0] & 0xf, FALSE ) == ~0u))
{
return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
}
......@@ -3353,14 +3352,12 @@ static DWORD receive_frame( struct netconn *netconn, DWORD *ret_len, enum socket
{
USHORT len16;
if ((ret = receive_bytes( netconn, (char *)&len16, sizeof(len16), &count ))) return ret;
if (count != sizeof(len16)) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
len = RtlUshortByteSwap( len16 );
}
else if (len == 127)
{
ULONGLONG len64;
if ((ret = receive_bytes( netconn, (char *)&len64, sizeof(len64), &count ))) return ret;
if (count != sizeof(len64)) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
if ((len64 = RtlUlonglongByteSwap( len64 )) > ~0u) return ERROR_NOT_SUPPORTED;
len = len64;
}
......@@ -3548,23 +3545,21 @@ static DWORD socket_close( struct socket *socket, USHORT status, const void *rea
}
if ((ret = receive_frame( netconn, &count, &socket->opcode ))) goto done;
if (socket->opcode != SOCKET_OPCODE_CLOSE || (count && count > sizeof(socket->reason)))
if (socket->opcode != SOCKET_OPCODE_CLOSE ||
(count && (count < sizeof(socket->status) || count > sizeof(socket->status) + sizeof(socket->reason))))
{
ret = ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
goto done;
}
if ((ret = receive_bytes( netconn, (char *)&socket->status, sizeof(socket->status), &count ))) goto done;
if (count != sizeof(socket->status))
if (count)
{
ret = ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
goto done;
}
socket->status = RtlUshortByteSwap( socket->status );
if (!(ret = receive_bytes( netconn, socket->reason, sizeof(socket->reason), &socket->reason_len )))
{
socket->state = SOCKET_STATE_CLOSED;
DWORD reason_len = count - sizeof(socket->status);
if ((ret = receive_bytes( netconn, (char *)&socket->status, sizeof(socket->status), &count ))) goto done;
socket->status = RtlUshortByteSwap( socket->status );
if ((ret = receive_bytes( netconn, socket->reason, reason_len, &socket->reason_len ))) goto done;
}
socket->state = SOCKET_STATE_CLOSED;
done:
if (async)
......
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